How can I use a TreeWalker to dump out the DOM

Posted by michael on Stack Overflow See other posts from Stack Overflow or by michael
Published on 2010-04-04T23:31:19Z Indexed on 2010/04/04 23:33 UTC
Read the original article Hit count: 437

Filed under:
|
|

Hi,

In w3c dom interface, there is DOMTreeWalker to traverse the DOM. I find this example which uses DOMTreeWalker:

http://www.java-tips.org/java-se-tips/org.w3c.dom/how-to-traverse-the-dom-tree-using-treewalker-2.html

But my question is How can I use the DOMTreeWalk to dump the dom structure and value to a file? i.e. I need to know when a parent start and a parent end so that I can do when I dump the dom to a file (i need to insert after each parent dumps its children:

<parent>
  <child a1="1" a2="2"/>
  <child a3="1" a4="3"/>
  <child a5="1" a6="5"/>
</parent>

© Stack Overflow or respective owner

Related posts about dom

Related posts about JavaScript