December 21, 2006 at 5:50 pm
<html>
<head>
<script type="text/javascript">
function getPage()
{
var objHTTP = new ActiveXObject("Microsoft.XMLHTTP")
alert ("Created HTTP object");
objHTTP.Open('GET','http://www.helpme.com/test.asp?InputZipCode=44320&OutputType=XML',false);
objHTTP.Send();
document.all['A1'].innerText= objHTTP.status;
document.all['A2'].innerText= objHTTP.statusText;
document.all['A3'].innerText= objHTTP.responsexml.getElementsByTagName('InputZipCode');
document.all['A4'].innerText= objHTTP.responsetext;
alert('The firstname is ' + firstnames[0]);
}
</script>
</head>
<body onload="getPage()">
<h2>Using the HttpRequest Object</h2>
<p>
<b>status:</b>
<span ID="A1"></span>
</p>
<p>
<b>status text:</b>
<span ID="A2"></span>
</p>
<p>
<b>response1:</b>
<br><span ID="A3"></span>
</p>
<p>
<b>response:</b>
<br><span ID="A4"></span>
</p>
</body>
</html>
I am attempting to query an XML output to a web page.
The above code is a sample of wht I'm running.
the response: line pulls all the raw xml which is good
but I'd like to put all the data in readable format.
The response1 line just returns [object] with no other data.
Is there away to feed the data to the web page in a readable way?
Eventually I'd like to insert the data into a database.
Can someone help me with this code.
December 22, 2006 at 4:44 am
The statement:
document.all['A3'].innerText= objHTTP.responsexml.getElementsByTagName('InputZipCode');
returns a collection of element nodes. You need to first restrict it to one node. Then you need to get the text for that node.
Try the following from
http://www.devguru.com/technologies/xmldom/quickref/document_getElementsByTagName.html
document.all['A3'].innerText= objHTTP.responsexml.getElementsByTagName('InputZipCode')[0].firstChild.nodeValue ;
This assumes that you have one InputZipCode and it has only text.
Russel Loski, MCSE Business Intelligence, Data Platform
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply