REXML is a conformant XML processor for the Ruby programming language. REXML is included in the standard library of Ruby.
Questions tagged [rexml]
124 questions
0
votes
1 answer
Rexml - Parsing Data
I have a XML File in the following format:

Paddy
- 11
- 2
0
votes
1 answer
How to get the attributes of an XML tag using Ruby with REXML?
I want to output an xml file in a specific way only using REXML with Ruby. Here is what the xml file looks like:
2408
joe@silva.com
Today
Hello…

Redson
- 2,098
- 4
- 25
- 50
0
votes
1 answer
String.encode is failing with cannot be performed with encoding 'UTF-8' because Apple's ICU doesn't allow it
I am working on iOS7 with RubyMotion 2.34, Motion-bundler 0.2.1, and rubysl-rexml 2.4.1.
I've gotten the following error when trying to parse an XML response from a server, down in the encoding part of REXML. However, I've also done the following to…

Dr. Polar Humenn
- 377
- 3
- 10
0
votes
0 answers
Does REXML support object dumping and loading
I'm using REXML for ruby serialization.
Is there a way for me to just call a method to dump the object to XML, and then call another method to load the XML data into a Ruby object?
For example, the Ox gem supports save and parse_obj methods to…

MxLDevs
- 19,048
- 36
- 123
- 194
0
votes
2 answers
How do I grab a really simple element using XML?
I'm struggling to figure out XPath and REXML, every single thing I try, even copied from books, returns nil. And I'm trying to do the simplest possible output of data... my file looks like
3002
I want to…

GreenTriangle
- 2,382
- 2
- 21
- 35
0
votes
1 answer
How to extract an XML tag ID and its value in Ruby from an XML document
Consider a XML document
Text2
I want to parse this document in ruby and make a hash like {id:"Text1", "id2":Text2}
I tried nokogiri and REXML tutorials but was not much…
Text1

Learner
- 59
- 8
0
votes
1 answer
Pretty-print to file with REXML
I am having trouble editing an XML file correctly. I want to remove certain elements and then add new ones.

GustavW
- 21
- 2
0
votes
1 answer
REXML how to get the first sibling in a schema
I am attempting to parse the information available in MLB GameDay. Here is an example file that I'm working with:
http://gd2.mlb.com/components/game/mlb/year_2014/month_04/day_05/gid_2014_04_05_anamlb_houmlb_1/game_events.xml
Specifically, here's…

randombits
- 47,058
- 76
- 251
- 433
0
votes
2 answers
REXML::Document.new take a simple string as good doc?
I would like to check if the xml is valid. So, here is my code
require 'rexml/document'
begin
def valid_xml?(xml)
REXML::Document.new(xml)
rescue REXML::ParseException
return nil
end
bad_xml_2=%{aasdasdasd}
…

user3037484
- 25
- 1
- 7
0
votes
1 answer
Why the original element got changed when I modify the copy created by .dup method? Ruby and REXML
I just tested the following steps in irb and got something odd:
require 'rubygems'
require 'rexml/document'
include REXML
e1=Element.new("E1")
e2=Element.new("E2")
e1.add_element(e2)
e1Dup=e1.dup
puts e1
puts…

user3672656
- 5
- 3
0
votes
1 answer
Ruby rexml xpath.each not traversing nodes
Hello stackoverflow I am having continuing problems with XML and Ruby.
# rexml
xmlfile = File.new("sample.xml")
xmldoc = REXML::Document.new xmlfile
root = xmldoc.root
# count = 0
XPath.each( xmldoc, "//CRDoc/speech/speaking") do |element|
…

CodeHard
- 125
- 14
0
votes
1 answer
Ruby XML Reading from one XML and parsing into another
XPath.each( xmldoc, "//speech/speaking") do |element|
# puts element.attributes['name']
# puts element.text
File.open(file_name + "_" + element.attributes['name'] + "-" + year + ".xml", 'a+') do |f|
f.write("" +…

CodeHard
- 125
- 14
0
votes
1 answer
How to get all leaf cell from an REXML element, and save them into a array?
Have a Ruby REXML element like below:
trans
ac
dc
default
C0…

user3672656
- 5
- 3
0
votes
1 answer
Deleting all child nodes and text of an element
With reXml using Ruby, I have a particular element and I want to completely clear out all its child nodes and text.
I just cannot work out how to do this.
Given this :
Delete all this
I want to delete…

Mongus Pong
- 11,337
- 9
- 44
- 72
0
votes
1 answer
Deployment fails because of obscure REXML setting?
I'm using EngineYard for my production system. My deployment has Ruby 1.9.3p392. I develop on Ruby 1.9.3p429.
I get notifications from a 3rd party server that contains large XML files (larger than 10K anyway).
After a new deployment, for some…

RubyRedGrapefruit
- 12,066
- 16
- 92
- 193