0

Using the Gem libxml-ruby, when we parse XML like so:

document = LibXML::XML::Parser.string( xmlData ).parse
for n in document.root.children
  # Do something
end

What we actually get is something like this:

root
-node empty
-node with data
-node empty 

Same thing with attributes, there's a blank one padding between those we actually care about. What we end up needing to use is :options => LibXML::XML::Parser::Options::NOBLANKS

Why? :(

Clucking Turtle
  • 922
  • 1
  • 11
  • 24

1 Answers1

0

(Not necessarily an answer, but need formatting.)

What does the XML look like?

This XML:

<baz>
  <plugh>ohai</plugh>
</baz>

may contain whitespace text nodes for the CR/LF and indentation between the <baz> and <plugh> opening tags, and the same for between the closing tags. This may or may not be significant whitespace depending on the nature of the XML. Structurally, it's different than:

<baz><plugh>ohai</plugh></baz>
Dave Newton
  • 158,873
  • 26
  • 254
  • 302