Skip to Main Content
XML Hacks
book

XML Hacks

by Michael Fitzgerald
July 2004
Intermediate to advanced content levelIntermediate to advanced
479 pages
12h 30m
English
O'Reilly Media, Inc.
Content preview from XML Hacks

Analyze Nodes with TreeViewer

View nodes in an XML document according to the XPath 1.0 data model.

The XPath 1.0 data model (http://www.w3.org/TR/xpath#data-model) views XML documents as containing seven possible node types:

Mike Brown and Jeni Tennison have created several stylesheets, available at http://skew.org/xml/stylesheets/treeview/, that visually represent all seven of the XPath node types. Such tools can be useful when trying to uncover less obvious nodes (namespace or whitespace-only text nodes) or when just learning about the XPath model. These stylesheets allow you to view an XML tree either in ASCII (ascii-treeview.xsl) or in HTML (tree-view.xml with tree-view.css). All three are available in the working directory where you extracted the file archive for the book.

When you apply ascii-treeview.xsl to time.xml using an XSLT processor such as Xalan by using this command:

xalan time.xml ascii-treeview.xsl

it will produce the text tree view of time.xml shown in Example 3-5.

Example 3-5. Output from ascii-treeview.xsl

root |_ _ _comment ' a time instant ' |_ _ _element 'time' | \_ _ _attribute 'timezone' = 'PST' |_ _ _text '\n ' |_ _ _element 'hour' | |_ _ _text '11' |_ _ _text '\n ' |_ _ _element 'minute' | |_ _ _text '59' |_ _ _text '\n ' |_ _ _element 'second' ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

XML Schema Complete Reference, The

XML Schema Complete Reference, The

Cliff Binstock, Chris Galtenberg, Mike Wooding, Chris Dix, Mitchell Smith, Dave Peterson
.NET & XML

.NET & XML

Niel M. Bornstein

Publisher Resources

ISBN: 0596007116Supplemental ContentErrata Page