Note that there are some explanatory texts on larger screens.

plurals
  1. POXML parse sub-parents of root node
    primarykey
    data
    text
    <p>Here's <strong>books.xml</strong>, an xml that I'm trying to traverse:</p> <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt; &lt;!-- Edited by XMLSpy® --&gt; &lt;bookstore&gt; &lt;book category="cooking"&gt; &lt;title lang="en"&gt;Everyday Italian&lt;/title&gt; &lt;author&gt;Giada De Laurentiis&lt;/author&gt; &lt;year&gt;2005&lt;/year&gt; &lt;price&gt;30.00&lt;/price&gt; &lt;/book&gt; &lt;book category="children"&gt; &lt;title lang="en"&gt;Harry Potter&lt;/title&gt; &lt;author&gt;J K. Rowling&lt;/author&gt; &lt;year&gt;2005&lt;/year&gt; &lt;price&gt;29.99&lt;/price&gt; &lt;/book&gt; &lt;book category="web"&gt; &lt;title lang="en"&gt;XQuery Kick Start&lt;/title&gt; &lt;author&gt;James McGovern&lt;/author&gt; &lt;author&gt;Per Bothner&lt;/author&gt; &lt;author&gt;Kurt Cagle&lt;/author&gt; &lt;author&gt;James Linn&lt;/author&gt; &lt;author&gt;Vaidyanathan Nagarajan&lt;/author&gt; &lt;year&gt;2003&lt;/year&gt; &lt;price&gt;49.99&lt;/price&gt; &lt;/book&gt; &lt;book category="web" cover="paperback"&gt; &lt;title lang="en"&gt;Learning XML&lt;/title&gt; &lt;author&gt;Erik T. Ray&lt;/author&gt; &lt;year&gt;2003&lt;/year&gt; &lt;price&gt;39.95&lt;/price&gt; &lt;/book&gt; &lt;/bookstore&gt; </code></pre> <p>I want to go to each book and extract all of its children's data, however, I'm having probems: It keeps returning <strong><em>null</em></strong> instead of the values of the text nodes. Here's my code:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script type="text/javascript" src="loadXML.js"&gt; &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;script type="text/javascript"&gt; xmlDoc=loadXMLDoc("books.xml"); var x = xmlDoc.getElementsByTagName("book"); for(var i=0;i&lt;x.length;i++) { var y = x[i].childNodes; for(var j=0;j&lt;y.length;j++) { document.write(y[j].nodeValue); document.write("&lt;br&gt;"); } document.write("&lt;br&gt;"); } &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload