How do I get a string into a Document?

J

Jim

I probably am not describing what I want to do very well. I'm using the
method described in http://jibbering.com/2002/4/httprequest.html to
obtain an html document generated by a cgi script. I would like to use
the DOM access methods, like getelmentbyid and/or loop through elements
included in the html.

As shown in the example, I do:

xmlhttp.open("GET", "/cgi-bin/getall.cgi",true);

and

var stringData = xmlhttp.responseText;

Now that stringData is truely a string of the entire html document. I
know I can parse the document manually but I was sort of hoping I could
stuff it into a document. I also recognize it would be possible to have
the cgi generate an xml document which I could parse easily, however the
eventual goal is to take the output of a proprietary cgi program that
spits out formatted html.

So am I barking up the wrong tree or is there a way to get there from here?

Thanks,
Jim.
 
M

Martin Honnen

Jim wrote:

var stringData = xmlhttp.responseText;

Now that stringData is truely a string of the entire html document. I
know I can parse the document manually but I was sort of hoping I could
stuff it into a document.
So am I barking up the wrong tree or is there a way to get there from here?

Consider loading the URI /cgi-bin/getall.cgi directly into an iframe
then you can access the DOM of the iframe. I don't know of any of the
mainstream browser currently allowing you to parse a string with a
complete HTML document markup into a DOM document without using a
frame/iframe.
 
J

Jim

Martin said:
Jim wrote:




Consider loading the URI /cgi-bin/getall.cgi directly into an iframe
then you can access the DOM of the iframe. I don't know of any of the
mainstream browser currently allowing you to parse a string with a
complete HTML document markup into a DOM document without using a
frame/iframe.
OK, thanks. I did try var doc = new Document(); but that generated an
error. Guess documents are not objects that can be instantiated.

Jim.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,432
Messages
2,571,681
Members
48,796
Latest member
Greg L.

Latest Threads

Top