However, if you parse the output of [$doc asXML] into a new dom tree,
the newline is now included in the value of the text node in question.
Here is some code to demonstrate what I mean:
# start code
package require tdom
proc demonstrate {} {
dom createNodeCmd -returnNodeCmd element elementNode
dom createNodeCmd -returnNodeCmd text textNode
dom createDocument test doc
[$doc documentElement] appendFromScript {
elementNode {}
set textnode [textNode "some text"]
}
puts "Original document as XML:"
puts [$doc asXML]
puts "Value of original text node between slashes: /[$textnode
nodeValue]/\n"
dom parse [$doc asXML] doc2
puts "Reparsed document as XML:"
puts [$doc2 asXML]
set newtextnode [$doc2 selectNodes {/test/text()}]
puts "Value of new text node between slashes: /[$newtextnode
nodeValue]/\n"
}
demonstrate
# end code
Is there a way to get tDOM to parse its own output into an input
identical to the original DOM tree, without gratuitous newlines?
Thanks,
Aric
I believe parsing with -keepEmpties and serializing with -indent none
should preserve all whitespace and linebreaks:
dom parse -keepEmpties [$doc asXML -indent none] doc2
--Koen
Indeed! In fact, it looks like -indent none does the trick, at least
in the minimal example I posted. Thanks for the quick and helpful
response.
Aric