Parsing XML in Javascript getElementsByTagName not working
- by Probocop
Hi, I am trying to parse the following XML with javascript:
<?xml version='1.0' encoding='UTF-8'?>
<ResultSet>
<Result>
<URL>www.asd.com</URL>
<Value>10500</Value>
</Result>
</ResultSet>
The XML is generated by a PHP script to get how many pages are indexed in Bing.
My javascript function is as follows:
function bingIndexedPages() {
ws_url = "http://archreport.epiphanydev2.co.uk/worker.php?query=bingindexed&domain="+$('#hidden_the_domain').val();
$.ajax({
type: "GET",
url: ws_url,
dataType: "xml",
success: function(xmlIn){
alert('success');
result = xmlIn.getElementsByTagName("Result");
$('#tb_actualvsindexedbing_indexed').val($(result.getElementsByTagName("Value")).text());
$('#img_actualvsindexedbing_worked').attr("src","/images/worked.jpg");
},
error: function() {$('#img_actualvsindexedbing_worked').attr("src","/images/failed.jpg");}
});
}
The problem I'm having is firebug is saying: 'result.getElementsByTagName is not a function'
Can you see what is going wrong?
Thanks