Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - Re: data island creation using reponseText >Thread Next - Re: data island creation using reponseText Re: data island creation using reponseTextTo: NULL Date: 7/6/2007 6:37:00 AM
On Jul 6, 3:28 am, "Anthony Jones" <A...@yadayadayada.com> wrote:
> <clockem...@alltel.net> wrote in message
>
> news:1183653614.908936.37170@n......
>
>
>
>
>
> > 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;
> > }
>
> I'm a bit confused why you need to use data islands?
> XMLHttpRequest has a ResponseXML property which will return an XML DOM when
> the response content type is "text/xml".- Hide quoted text -
>
> - Show quoted text -
How can I set that in client-side JavaScript?
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
