Good morning.
I have the next xml file with sub childs, and I want to read them for populate the data into a table. Right now, I know how to do it in a simple way, with childnodes, but I really dont know how to achieve it for getting the sub childnodes.
<Result>
<Record id="000231">
<AC_NPD/>
<Name>Company1</Name>
<AC_CPR>00003</AC_CPR>
<AC_ALM>00</AC_ALM>
<AC_FEC>12/01/2007</AC_FEC>
<AC_LNA ncols="6">
<Row>
<Column>000084</Column>
<Column>1.230</Column>
<Column/>
<Column/>
<Column/>
<Column/>
</Row>
</AC_LNA>
<AC_FSE>12/01/2007</AC_FSE>
<AC_AV/>
<AC_UFH ncols="3"/>
</Record>
</Result>
Now, I paint the table with the results, using this script:
So, if anyone knows how to get the sub child node i would be very gratefully.Code:<script> if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.open("GET","xml/pruebas/resp2.asp",false); xmlhttp.send(); xmlDoc=xmlhttp.responseXML; document.write("<table class='table table-striped table-condensed table-bordered' id='example'>"); document.write("<thead>"); document.write("<tr class='odd gradeX'>"); document.write("<th>Sale</th>"); document.write("<th>Name</th>"); document.write("<th>Date</th>"); document.write("<th>Date Sale</th>"); document.write("<th>Item</th>"); document.write("<th>Quantity</th>"); document.write("<th class='hidden-phone'>Price</th>"); document.write("<th class='hidden-phone'>Total</th>"); document.write("<th>Sale Item</th>"); document.write("<th>Button</th>"); document.write("</tr>"); document.write(" </thead>"); var x=xmlDoc.getElementsByTagName("Record"); for (i=0;i<x.length;i++) { document.write("<tr>"); document.write("<td>"); document.write("</td>"); document.write("<td>"); document.write(x[i].getElementsByTagName("Name")[0].childNodes[0].nodeValue); document.write("</td>"); document.write("<td>"); document.write(x[i].getElementsByTagName("AC_FEC")[0].childNodes[0].nodeValue); document.write("</td>"); document.write("<td>"); document.write(x[i].getElementsByTagName("AC_FSE")[0].childNodes[0].nodeValue); document.write("</td>"); document.write("<td>"); document.write("</td>"); document.write("<td>"); document.write("</td>"); document.write("<td>"); document.write("</td>"); document.write("<td>"); document.write("</td>"); document.write("<td> <a data-toggle='modal' class='btn' href='sale.asp?&number="); document.write(x[i].getElementsByTagName("AC_FEC")[0].childNodes[0].nodeValue); document.write("' data-target='#myModal'> My Sale </a> "); document.write(" </td>"); document.write("</tr>"); } document.write("</table>"); </script>
Best regards.


Reply With Quote


Bookmarks