Hi there again all
I am having trouble with retrieving data from an xml file
Here is the code I am using can anyone tell me where my problem lies?
function GetxmlHttpObject()
{
var xmlHttp=null;
try
{
// Firefox, Opera, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}
function GetxmlHttpObject() {
var xmlDoc = GetxmlHttpObject();
xmlDoc.load('coords.xml');
var len = xmlDoc.childNodes.length;
var newcoords = xmlDoc.childNodes(0).childNodes(0).firstChild.text;
parent.document.receiver.thepos.value = len;
}
as I am very new to Javascript and AJAX I am not very familiar with the process yet and I have not been able to get the xml loaded.
Obviously I am declaring this all wrong as I receive the error that load is not a function of xmlDoc!
Hi there again I have changed tactics and am now using pototype.js
I seem to be able to get the tags though I am not sure how to access the text values of each tag.
can anyone help?
function makeMarkerXml() {
new Ajax.Request('coords.xml',
{
method:'post',
onSuccess: function(transport){
var coordTags = transport.responseXML.getElementsByTagName('coords');
var coord =coordTags[0].text;///need to find the text and this doesn't work
parent.document.receiver.thecoord.value = 'XML child:'+coord;
},
onFailure: function(){ alert('Call failed') }
});
}
Thanks though this didn’t work.
I can see the xml is loaded though firebug though I just can’t seem to work out why I can’t get the text value of each tag. I know theres nothing wrong with the xml as I can load and iterate the values in both flash AS and php.
anyone know how to retrieve the text value of a child node in xml.
Here is the xml format