Questions tagged [rexml]

REXML is a conformant XML processor for the Ruby programming language. REXML is included in the standard library of Ruby.

124 questions
11
votes
2 answers

Ruby convert single quotes to double quotes in XML

Despite the fact that XML attributs can be defined using single or double quotes, my user is trying to integrate my software with another one that will not accept single quoted attribut values. I user REXML to generate my XMLs. Is there a way to…
Ricardo Acras
  • 35,784
  • 16
  • 71
  • 112
11
votes
2 answers

REXML :: RuntimeError (entity expansion has grown too large)

After upgrading to Ruby-1.9.3-p392 today, REXML throws a Runtime Error when attempting to retrieve an XML response over a certain size - everything works fine and no error is thrown when receiving under 25 XML records, but once a certain XML…
user2203451
  • 221
  • 2
  • 7
10
votes
2 answers

converting from xml name-values into simple hash

I don't know what name this goes by and that's been complicating my search. My data file OX.session.xml is in the (old?) form
Marcos
  • 4,796
  • 5
  • 40
  • 64
9
votes
1 answer

Rexml - pretty print with text inline and child tags indented

I'm building an xml doc with REXML, and want to output to text in a particular way. The doc is a list of CuePoint tags, and the ones that i've generated with Element.new and add_element are all mushed together into a single line like this:…
Max Williams
  • 32,435
  • 31
  • 130
  • 197
6
votes
3 answers

Ruby Unit Test : Is this a Valid (well-formed) XML Doc?

I'm creating an XML document: I want to unit test at least to make sure it's well-formed. So far, I have only been able to approximate this , by using the 'hasElements' in the REXML library. Is there a better way ? Preferably using built-in…
monojohnny
  • 5,894
  • 16
  • 59
  • 83
5
votes
1 answer

Get node name with REXML

I have an XML, which can be like 123 or like other value or the root node can be something completely…
ytg
  • 1,755
  • 2
  • 23
  • 41
5
votes
1 answer

Reading xml file using REXML, says ...

I have a very simple xml file that I am trying to access:
hello world
I'm doing this so far: file = File.open("#{Rails.root}/public/files/#{file_id}.xml", "r") xml = file.read doc =…
Blankman
  • 259,732
  • 324
  • 769
  • 1,199
4
votes
2 answers

XML parsing in Ruby

I am using a REXML Ruby parser to parse an XML file. But on a 64 bit AIX box with 64 bit Ruby, I am getting the following error: REXML::ParseException: #
Ricketyship
  • 644
  • 2
  • 7
  • 22
4
votes
3 answers

Why can't REXML parse CDATA preceded by a line break?

I'm very new to Ruby, and trying to parse an XML document with REXML that has been previously pretty-printed (by REXML) with some slightly erratic results. Some CDATA sections have a line break after the opening XML tag, but before the opening of…
Andrew M
  • 9,149
  • 6
  • 44
  • 63
3
votes
1 answer

REXML - How to extract a single element

I am writing some acceptance tests in ruby which involve asserting the presence of values in response XML. My XML is like this: whatever There are other attributes but what is…
Adrian
  • 143
  • 1
  • 4
  • 13
3
votes
4 answers

Getting elements in order with REXML XPath

I'd like to iterate through all the and elements in an XML file, and add a unique id to each. The approach I've tried so far is: @xml.each_element('//HeadA | //HeadB') do |heading| #add a new id end The problem is, the nodeset…
Skilldrick
  • 69,215
  • 34
  • 177
  • 229
3
votes
2 answers

Using XPath: find last text node of each paragraph under the root node

I want to trim trailing whitespace at the end of all XHTML paragraphs. I am using Ruby with the REXML library. Say I have the following in a valid XHTML file:

hello world a

Hi there

The End

I want to end up with…
Diego Barros
  • 2,071
  • 2
  • 33
  • 45
3
votes
2 answers

Ruby/REXML: Change a tag value from XPath

I have a base XML that I need to modify through a Ruby script. The XML looks like this: So and So I am able to print the value of : require…
Astaar
  • 5,858
  • 8
  • 40
  • 57
2
votes
1 answer

Getting the InnerXML of an Element using REXML Document and Ruby

I have looked everywhere I think, but not found an answer. I am consuming a SOAP API and I wish to store only part of the response in the database as XML. The code is as follows: require 'rexml/document' doc =…
vvohra87
  • 5,594
  • 4
  • 22
  • 34
2
votes
1 answer

Novice XML Parsing

I am learning XML parsing with RUBY(infact never did any XML parsing before). Plz refer this link - http://www.tutorialspoint.com/ruby/ruby_xml_xslt.htm In the DOM-like Parsing example, it prints all Movie Title followed by Movie Type. But i want to…
rajya vardhan
  • 1,121
  • 4
  • 16
  • 29
1
2 3
8 9