XMLHttpRequest to read data from XML file

All modern browsers support XML parser to read data from a XML file. Here is a sample code to read data from XML

<script type="text/javascript">
if (window.XMLHttpRequest)
{ my_xml=new XMLHttpRequest();
}
else
{
my_xml=new ActiveXObject("Microsoft.XMLHTTP");
}
</script>

Related Tutorial
XML basics
PHP & XML
XMLHttpRequest is widely used in Ajax to interact with server without reloading the page. Along with any server side scripting language we can develop powerful applications. You can read more on our PHP Ajax section.

We will be using our sample XML file

https://www.plus2net.com/php_tutorial/file-xml-demo.xml

Here is the code to read the xml file.

<script type="text/javascript">
if (window.XMLHttpRequest)
{ my_xml=new XMLHttpRequest();
}
else
{
my_xml=new ActiveXObject("Microsoft.XMLHTTP");
}
/////////////////////////////
my_xml.open("GET",'https://www.plus2net.com/php_tutorial/file-xml-demo.xml',false);
my_xml.send();
xml_str=my_xml.responseXML;
</script>

Displaying node value of xml file

Your Rating





Post your comments , suggestion , error , requirements etc here .




We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
©2000-2019 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer