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
1
vote
3 answers

How to get the absolute node path in XML using XPath and Ruby?

Basically I want to extract the absolute path from a node to root and report it to the console or a file. Below is the current solution: require "rexml/document" include REXML def get_path(xml_doc, key) XPath.each(xml_doc, key) do |node| …
Petro Semeniuk
  • 6,970
  • 10
  • 42
  • 65
1
vote
1 answer

How to get tags that don't have specific ancestor and descendant using REXML

I'd like to get A tags and the B tag from the following XML, but I want to remove the second A tag: ......many other tags. abc <<==== I want to remove this A tag from result. def foo hoge bar
user19701
  • 9
  • 2
1
vote
1 answer

Writing namespaced XML with REXML

I'm working with some XML that involves multiple namespaces (specifically ResourceSync, which embeds namespaced tags in Sitemap documents). When I create REXML elements, I can set a global namespace: foo =…
David Moles
  • 48,006
  • 27
  • 136
  • 235
1
vote
1 answer

Ruby 2.2 Using REXML

I have followed much tutorials about Ruby 2.2 and REXML. This is an example of my xml: And this is what I currently have as code: xml = "
Jad
  • 76
  • 8
1
vote
1 answer

Injecting an XML fragment into the current document from an external file

I'm currently parsing an XML file using REXML and trying to come up with a way of inserting an XML fragment from an internal file. Currently, I'm using some logic like the following: doc.elements.each('//include') do |element| handleInclude(…
makenai
  • 463
  • 2
  • 12
1
vote
2 answers

Is there a way of iterating through a specific XML tag in Ruby?

Is it possible to iterate over a specific XML tag in Ruby? In my case I want iterate over the desc tag in the following XML code: 2408 joe@silva.com Today Hello…
Redson
  • 2,098
  • 4
  • 25
  • 50
1
vote
0 answers

Rake task updates a target differently than I expect

I've an xml file which I'm trying to update through a rake task. Following are the xml and rake files: test.xml
1
vote
0 answers

Loading UTF-16 xml document with REXML

Wondering if it is possible to load a utf-16 xml file with REXML 3.1.7.3 and ruby 1.9.3. Here is the xml data in a file u16.xml w/o BOM:
Rock Hyrax
  • 11
  • 3
1
vote
1 answer

Rails sidekiq pass REXML::Element

I am attempting to send an REXML::element to a worker using sidekiq. However when I do so I get an error: ActiveSupport::JSON::Encoding::CircularReferenceError In this case I am taking an XML document that is stored online and running one worker…
1
vote
3 answers

error related to REXML

I'm not sure it's REXML or ruby issue. But this is happening when I work with REXML. The program below should access elements of each xml file in the directory. #!/usr/bin/ruby -w require 'rexml/document' include REXML p "Current directory was: "…
Askar
  • 5,784
  • 10
  • 53
  • 96
1
vote
1 answer

accessing xml file with REXML

sample.xml
MID-0000001 Bruce 0000001
Askar
  • 5,784
  • 10
  • 53
  • 96
1
vote
1 answer

Ruby: How to find XML child element from specific element using xpath?

Given xml Goal: Get each "b" first, then get the "c" under that "b", like result below. With XPath for searching child. for
Jim Horng
  • 1,587
  • 1
  • 13
  • 23
1
vote
1 answer

Iterative Parsing XML

Just getting started with Ruby and have a newbie question re parsing XML. I'm trying REXML (yes, I know hpricot and others exist, but I am starting with REXML to learn.) The problem is how to iteratively proceed through a XML doc like this:
user188836
1
vote
1 answer

How to loop through XML children nodes with Ruby REXML

I have a XML document that looks something like this: 1 100 pool 400 pluminbing
user1280971
  • 105
  • 1
  • 9
1
vote
2 answers

how do I stop REXML from escaping characters?

I'm pulling a bunch of data from one database and feeding it into an application via XML. So I start with re_objects_xml = Document.new re_objects_xml.context[:attribute_quote] = :quote re_objects_xml.context[:raw] = 'true' …
1 2 3
8 9