Note that there are some explanatory texts on larger screens.

plurals
  1. POxml dom parsing
    primarykey
    data
    text
    <p>I can't figure out how to access the data between the inner nested tags. When I run this javascript, all I see is "Null". </p> <p>Here is what my xml file named "bboard.xml" looks like:</p> <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt; &lt;!-- Designed by Someone --&gt; &lt;bulletinboard&gt; &lt;article&gt; &lt;title lang="en"&gt;&lt;h2&gt;eeeeeeeeegg #1&lt;/h2&gt;&lt;/title&gt; &lt;detail&gt;&lt;span class="detail"&gt;aaaaapple&lt;/span&gt;&amp;lt;a href="../data/csr.html#artcl1"&gt; ...more &amp;lt;/a&gt;&lt;/detail&gt; &lt;date&gt;12/09/09&lt;/date&gt; &lt;/article&gt; &lt;/bulletinboard&gt; </code></pre> <p>Here is the javascript named "loadxmldoc.js":</p> <pre><code>function loadXMLDoc(dname) { try //Internet Explorer { xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); } catch(e) { try //Firefox, Mozilla, Opera, etc. { xmlDoc=document.implementation.createDocument("","",null); } catch(e) {alert(e.message)} } try { xmlDoc.async=false; xmlDoc.load(dname); return(xmlDoc); } catch(e) {alert(e.message)} return(null); } </code></pre> <p>And finally, here is the actual HTML page where I want to display the result of javascript. It is called "javdemo.html":</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script type="text/javascript" src="loadxmldoc.js"&gt; &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div&gt; &lt;script type="text/javascript"&gt; xmlDoc=loadXMLDoc("bboard.xml"); var x=xmlDoc.getElementsByTagName("title"); var y=xmlDoc.getElementsByTagName("detail"); var z=xmlDoc.getElementsByTagName("date"); document.write("&lt;h4&gt;"+"A Live Bulletin Board"+"&lt;/h4&gt;"); for (i=0;i&lt;x.length;i++) { document.write("&lt;h1&gt;"+x[i].childNodes[0].nodeValue+"&lt;/h1&gt;"); document.write(y[i].childNodes[0].nodeValue); document.write(z[i].childNodes[0].nodeValue); document.write("&lt;p&gt;"+"&amp;nbsp;"+"&lt;/p&gt;"); // document.write("&lt;/div&gt;") } &lt;/script&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>This probably won't show the full code in your browser. By the way how do you escape html tags here on stack overflow?</p>
    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.
 

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