Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Removing extra #text elements from DOM tree

 
Tony Walters
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hiya
Bit of a newby question probably.
I have an xml doument which has been parsed by DOM. The document looks like this:
<catalog>
<book>
stuff here
</book>
</catalog>
The DOM tree appears to be as follows:
catalog
/ | \
#text book #text
I'm sure I have read that by inlcuding a DOCTYPE in the xml document, linking to a DTD, I can get rid of the unnecessary #text elements in the DOM tree, but this does not seem to work.
Any suggestions would be *very* much appreciated as I have already wasted a day on this! Doh!
 
Naren
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a method named isIgnoringElementContentWhitespace() in the class DocumentBuilderFactory (package: javax.xml.parsers )
Set it to 'true' before you get an instance of DocumentBuilder from it.
 
Tony Walters
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for that, I'll give it a go.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic