S
SpaceMarine
hello,
my ASP.NET page uses javascript to retrieve XML data from another ASPX
page. i do this like so (snippets for example):
var ajaxResults;
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", "getData.aspx", true);
xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState == 4) //ready
{
if (xmlhttp.status == 200) //success
{
//alert('success');
var xml = xmlhttp.responseXML;
//return cross-browser DOM object
if (xml.documentElement)
ajaxResults = xml.documentElement;
} else {
//alert('There was a problem retrieving the data:\n' +
xmlhttp.statusText);
}
}
}
xmlhttp.send(null)
....which populates "ajaxResults". the data looks like:
<results timestamp="6/20/2008 11:34:33 AM">
<dataItem value="1">Call for Service</dataItem>
</results>
....cool. i can then use this in JS like so:
var ddlItems = document.getElementById("ddlItems");
var i;
for (i = 0; i < resultNodes.length; i++){
//add an item to list
ddlItems.options.length ++;
ddlItems.options.value = i; // ? how do i get the attribute of the
node?
ddlItems.options.text = resultNodes.firstChild.nodeValue; //
gets TEXT of "<dataItem>"
}
....all well and good (enough for me). but the question: how do i parse
the *attribute* values from my above returned XML object?
thanks,
matt
my ASP.NET page uses javascript to retrieve XML data from another ASPX
page. i do this like so (snippets for example):
var ajaxResults;
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", "getData.aspx", true);
xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState == 4) //ready
{
if (xmlhttp.status == 200) //success
{
//alert('success');
var xml = xmlhttp.responseXML;
//return cross-browser DOM object
if (xml.documentElement)
ajaxResults = xml.documentElement;
} else {
//alert('There was a problem retrieving the data:\n' +
xmlhttp.statusText);
}
}
}
xmlhttp.send(null)
....which populates "ajaxResults". the data looks like:
<results timestamp="6/20/2008 11:34:33 AM">
<dataItem value="1">Call for Service</dataItem>
</results>
....cool. i can then use this in JS like so:
var ddlItems = document.getElementById("ddlItems");
var i;
for (i = 0; i < resultNodes.length; i++){
//add an item to list
ddlItems.options.length ++;
ddlItems.options.value = i; // ? how do i get the attribute of the
node?
ddlItems.options.text = resultNodes.firstChild.nodeValue; //
gets TEXT of "<dataItem>"
}
....all well and good (enough for me). but the question: how do i parse
the *attribute* values from my above returned XML object?
thanks,
matt