Thanks for the reply. Are you telling me to do something like this...
PHP Code:
<script type="text/javascript"> xmlDoc=loadXMLDoc("news.xml");
document.write("<h2>" + xmlDoc.getElementsByTagName("title")[0].childNodes[0].nodeValue + "</h2>"); document.write(xmlDoc.getElementsByTagName("author")[0].childNodes[0].nodeValue + "<br>" + "<br>"); document.write(xmlDoc.getElementsByTagName("message")[0].childNodes[0].nodeValue); </script> <p><br></p> <script type="text/javascript"> xmlDoc=loadXMLDoc("news.xml");
x=xmlDoc.getElementsByTagName("title"); for (i=0;i<x.length;i++) { document.write("<h2>"); document.write(x[i].childNodes[0].nodeValue); document.write("</h2>"); } x=xmlDoc.getElementsByTagName("author"); for (i=0;i<x.length;i++) { document.write(x[i].childNodes[0].nodeValue); document.write("<br>"); document.write("<br>"); } x=xmlDoc.getElementsByTagName("message"); for (i=0;i<x.length;i++) { document.write(x[i].childNodes[0].nodeValue); document.write("<br>"); } </script>
This only works if I have only two articles in my XML file. If I have more than two it shows the titles, authors, and messages together. Like I said, I'm really new to XML and am still trying to learn. The w3schools tutorial isn't very clear. If you could show me some code with an explanation on why that's the code you came up with it would be great.
Thanks
|