By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,818 Members | 2,121 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,818 IT Pros & Developers. It's quick & easy.

How do I get a string into a Document?

P: n/a
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.
Sep 4 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a


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.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Sep 4 '06 #2

P: n/a
Jim
Martin Honnen wrote:
>

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.
OK, thanks. I did try var doc = new Document(); but that generated an
error. Guess documents are not objects that can be instantiated.

Jim.
Sep 6 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Browse more JavaScript / Ajax / DHTML Questions on Bytes