Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trying to render XML in web page using javascript

Status
Not open for further replies.

DBAJDS

MIS
Dec 21, 2006
2
US
<html>
<head>
<script type="text/javascript">
function getPage()
{
var objHTTP = new ActiveXObject("Microsoft.XMLHTTP")
alert ("Created HTTP object");
objHTTP.Open('GET','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 what 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.
 
>document.all['A3'].innerText= objHTTP.responsexml.getElementsByTagName('InputZipCode');
[tt]document.all['A3'].innerText= objHTTP.responsexml.getElementsByTagName('InputZipCode')[red][0].text[/red];[/tt]
It returns a collection of nodes. The above takes the first ([0]) for illustration.
 
Thank You Guys for the help.
<html>
<head>
<script type="text/javascript">
function getPage()
{
var objHTTP = new ActiveXObject("Microsoft.XMLHTTP")
var url1="alert ("Created HTTP object");
objHTTP.Open('GET','fullurl');
alert ("The GET call seems not to work on your internet site!")
objHTTP.Send();
document.all['A1'].innerText= objHTTP.status;
document.all['A2'].innerText= objHTTP.statusText;
document.all['A3'].innerText= objHTTP.responseText;



}
</script>
</head>

<body>
<h2>Using the HttpRequest Object</h2>
<input type=button onclick="getPage()" value="GO">
<p>
<b>status:</b>
<span ID="A1"></span>
</p>

<p>
<b>status text:</b>
<span ID="A2"></span>
</p>

<p>
<b>response:</b>
<br><span ID="A3"></span>
</p>



</body>
</html>


I am attempting to make the input dynamic now.
When I run the above code. It returns the error:
The system cannot locate the source specified.

When I run the debugger the following error is displayed
msxml3.dll: Unspecified error
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top