Reputation: 8379
Below is my HTML
<table width="100%">
<tr><td><center><b>Browse your XML File below.</b></td></center> </tr>
<tr><td><center><input type="file" id="location"></center></td></tr>
<tr><td><center><input type="button" id="load" value="Load XML"></center></td></tr>
</table>
Below is my Code which I am using to load XML
$('#load').bind('click',function()
{
var localfile = $('#location').val();
alert(localfile);
var xmlDoc;
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = false;
xmlDoc.load(localfile);
if(xmlDoc.readyState == 4)
{
alert("success"); // Till here this is executing fine...
var readyXML = $.parseXML( xmlDoc );
var xml = $(readyXML);
xml.find('Name').each(function()
{
alert($(this).text());
});
}
});
It seems there is(are) mistake(s) in the code..
Please help me on this to correct the code..
Upvotes: 0
Views: 4620
Reputation: 1287
jQuery.parseXML
takes a string as first argument. Have a look at the internals.
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = false;
xmlDoc.load(localfile);
jQuery(xmlDoc).find('Name').each(function() {
alert($(this).text());
});
Upvotes: 2