W
Wes Gamble
All,
Recently upgraded to Ruby 1.8.6 and having some backwards-compatibility
problems with REXML given it's new formatting setup.
Basically, I have a XML document with three elements underneath the
root. After I completely generate the XML, I use the following code to
pretty-print it out:
formatter = REXML::Formatters:efault.new
File.open("#{@file_path}", 'w') do |f|
formatter.write(@document, f)
end
What appears to happen, however, is that only the _first_ subordinate
element is pretty - printed, and the rest of the contents of the root
element are printed on one line after the first element ends.
It currently looks like this:
<root_elem>
<first_elem>
...pretty-printed contents of first_elem...
</first_elem><second_elem>...inline contents of
second_elem...</second_elem><third_elem>...inline contents of
third_elem....</third_elem>
</root_elem>
The consumer of this XML is unable to parse this. Changing the consumer
is not possible at this point, so I need to fix how this is output.
What I want to see is:
<root_elem>
<first_elem>
...pretty-printed contents of first_elem...
</first_elem>
<second_elem>
...pretty-printed contents of second_elem...
</second_elem>
<third_elem>
...pretty-printed contents of third_elem....
</third_elem>
</root_elem>
My guess is that I will need to write out each element separately with a
formatter, since the formatting of the document that I invoked doesn't
appear to propagate down into each element.
Am I on the right track?
Thanks,
Wes
Recently upgraded to Ruby 1.8.6 and having some backwards-compatibility
problems with REXML given it's new formatting setup.
Basically, I have a XML document with three elements underneath the
root. After I completely generate the XML, I use the following code to
pretty-print it out:
formatter = REXML::Formatters:efault.new
File.open("#{@file_path}", 'w') do |f|
formatter.write(@document, f)
end
What appears to happen, however, is that only the _first_ subordinate
element is pretty - printed, and the rest of the contents of the root
element are printed on one line after the first element ends.
It currently looks like this:
<root_elem>
<first_elem>
...pretty-printed contents of first_elem...
</first_elem><second_elem>...inline contents of
second_elem...</second_elem><third_elem>...inline contents of
third_elem....</third_elem>
</root_elem>
The consumer of this XML is unable to parse this. Changing the consumer
is not possible at this point, so I need to fix how this is output.
What I want to see is:
<root_elem>
<first_elem>
...pretty-printed contents of first_elem...
</first_elem>
<second_elem>
...pretty-printed contents of second_elem...
</second_elem>
<third_elem>
...pretty-printed contents of third_elem....
</third_elem>
</root_elem>
My guess is that I will need to write out each element separately with a
formatter, since the formatting of the document that I invoked doesn't
appear to propagate down into each element.
Am I on the right track?
Thanks,
Wes