Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries [Thread Prev] >Thread Next - Re: data island creation using reponseText data island creation using reponseTextTo: NULL Date: 7/5/2007 9:40:00 AM
I welcome all suggestions as to how to solve the following problem,
and I am fully prepared for mountains of criticism!.
I am now prohibited from using XMLHttpRequest and template queries to
return data from an SQL database as I had previously done. Therefore,
I have been using an XMLHttpRequest to return the responseText of an
aspx page that adds the returned data to a blank page using
Response.Write. The blank aspx page has the following XML added to it
by code.
<xml>
<loaninfo>
<borrower>
<firstname>John</firstname>
<middlename>Fred</middlename>
<lastname>Harris</lastname>
</borrower>
<borrower>
<firstname>Frank</firstname>
<middlename>Bob</middlename>
<lastname>Smith</lastname>
</borrower>
</loaninfo>
</xml>
I use the following JavaScript code to return this xml to the aspx
page where it is needed. The aspx page has the following data island
included within the html.
<xml id="xmlDataIsland">
</xml>
The http variable below has been properly set elsewhere in the code. I
am just trying to minimize the necessary code inclusion.
var url = "CreateXMLFile.aspx?strSearch=" + strSearchTerm;
http.open("GET", url, true);
http.onreadystatechange = handleHttpManualSearch;
http.send(null);
function handleHttpManualSearch() {
if (http.readyState == 4)
{
var strXML = http.responseText;
document.getElementById("xmlDataIsland").InnerXml = strXML;
alert("strXML = " +
document.getElementById("xmlDataIsland").InnerXml);
}
The alert displays the xml exactly as it appears on the aspx page from
which it was taken, including the <xml> tags. However, I have failed
to find a way to refer to elements within the data island (I have also
removed the <xml> tags from the responseText, which did not solve the
problem). Is there a way in which I can step through the borrower
nodes to obtain the data contained within, and make use of it in
JavaScript? I was looking for something similar to the way that I
would handle a responseXML in the following manner.
var xmlDocument = http.responseXML;
var root = xmlDocument.documentElement;
if(root.getElementsByTagName('Message').length > 0)
{
var strMessage =
root.getElementsByTagName('borrower').item(0).firstChild.data;
}
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
