Posts Tagged "xml"

How to export the data from MySQL into a XML file with PHP?

There are a couple of ways to export data from MySQL to a XML file. This post looks at how to export the data from MySQL into a XML file with PHP. The example code below uses the raw mysql_* functions but it should be easy enough to substitute a database library’s functions instead. It also writes the data out line by line to the XML file whereas you could buffer the whole file in memory and write it out…

Read More

Convert xml to html

This chapter explains how to display XML data as HTML. In the example below, we loop through an XML file (test.xml), and display each element as an HTML table row: <script type=”text/javascript”> var xmlDoc; if (window.XMLHttpRequest) { xmlDoc=new window.XMLHttpRequest();“GET”,”test.xml”,false); xmlDoc.send(“”); xmlDoc=xmlDoc.responseXML; } // IE 5 and IE 6 else if (ActiveXObject(“Microsoft.XMLDOM”)) { xmlDoc=new ActiveXObject(“Microsoft.XMLDOM”); xmlDoc.async=false; xmlDoc.load(“test.xml”); } document.write(“<table>”); var x=xmlDoc.getElementsByTagName(“TEST”); for (i=0;i<x.length;i++) { document.write(“<tr><td><b>”); document.write(x[i].getElementsByTagName(“SNIPPET”)[0].childNodes[0].nodeValue); document.write(“</b></td></tr><tr><td>”); document.write(x[i].getElementsByTagName(“NAME”)[0].childNodes[0].nodeValue); document.write(“</td></tr><tr><td>”); document.write(x[i].getElementsByTagName(“EMAIL”)[0].childNodes[0].nodeValue); document.write(“</td></tr><tr><td>”); document.write(x[i].getElementsByTagName(“WEBSITE”)[0].childNodes[0].nodeValue); document.write(“</td></tr><tr><td>”); document.write(x[i].getElementsByTagName(“LICENSE”)[0].childNodes[0].nodeValue); document.write(“</td></tr>”); } document.write(“</table>”); </script> * We…

Read More