Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

View HTML source in tree view?

Tags:

html

treeview

I'd like to analyze the structure of some complex web pages that I've visited. Manually parsing out tags in the HTML source is tedious and prone to errors.

I'd like to find a utility that will accept HTML source (or a URL) as input, and show the hierarchical arrangement of the HTML elements, including source and id attributes, preferably in a treeview.

I was confident that it should be easy to find such a tool, but a few Google searches haven't turned up anything for me. I'm still confident that such a tool exists. Can the community help me find something? (I'm a Windows user and of course would prefer free if possible.)

like image 585
The Demigeek Avatar asked May 13 '11 14:05

The Demigeek


People also ask

What is an HTML tree?

Each HTML document can actually be referred to as a document tree. We describe the elements in the tree like we would describe a family tree. There are ancestors, descendants, parents, children and siblings. It is important to understand the document tree because CSS selectors use the document tree.

How do you create a hierarchy in HTML?

You can use unordered lists to create a hierarchy (the <ul> and <li> tags). This can give you a tree structure which is semantically valid, and on top of that you can do whatever you like to express it in interesting ways, either through CSS or Javascript. Check out Listutorial for a great series of worked examples.

How can create tree structure in HTML using jquery?

First we need to prepare the HTML. In the tree view we have Parent Nodes, Child Nodes, Nodes. To create nodes we will use the LI and UL tags of HTML. To represent the parent node we will use a LI tag just above the UL.


2 Answers

IE8+ and Chrome both have wonderful developer tools built right in. Just visit a webpage and in IE, press F12, and in Chrome, go to wrench->tools->developer tools. They both show the tree view of the page as well as let you modify it. They're both very powerful.

IE9 Developer ToolsChrome Developer Tools

like image 55
Thomas Shields Avatar answered Oct 21 '22 17:10

Thomas Shields


Most browsers have a DOM viewer built in. Firefox has a third party extension that provides this.

These will all show the DOM after error recovery has been performed by the browser, before then you can't be sure that a valid tree could be constructed.

like image 44
Quentin Avatar answered Oct 21 '22 17:10

Quentin