How to print html dom tree?
-
i have a DOM tree of a parsed html file. the tree is made of nodes which hold a string and an arraylist of children nodes. i'm stumped on how to print out the html code equivalent of the tree. for simplicity, the DOM tree doesn't have any complicated stuff, just a few tags and some text. for example: html ----body --------center ------------the ------------em ----------------quick ------------brown fox this tree should be printed like: <html> <body> <center> the <em> quick </em> brown fox </center> </body> </html> i can't get the tree to print out the closing tags correctly. any help?
-
Answer:
When you say that the closing tags don't print correctly, do you mean that they don't print at all, or that they don't print in the order the reverse order to that in which they were opened, or what? If they don't print at all, that could be because you have not explicitly included them in your programme. The DOM is a collection of elements, not of tags. Each element (rather most elements) have both an opening tag and a closing tag. However in the DOM they are represented as a single element. Chapter 12 of Eloquent Javascript (available online at http://eloquentjavascript.net/chapter12.html#exercise1 ) provides an example of printing out the DOM which may help. To see the solution click on "show solution".
some guy named mike at Yahoo! Answers Visit the source
Related Q & A:
- How to dispaly HTML page in Silverlight application?Best solution by devproconnections.com
- How do you search DOM elements using CSS selectors in Chrome?Best solution by Stack Overflow
- How to Convert Html to PDF?Best solution by Stack Overflow
- How tall is the Christmas tree in Rockefeller Center?Best solution by Yahoo! Answers
- How tall is the tallest tree on the earth?Best solution by ChaCha
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.