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

Converting plaintext to DOM objects

Tarantulus
100+
P: 114
Hi All,

I have what I believe is a complex problem, but hopefully you'll be able to provide me with a simple answer.

I'm using XMLHttpRequest() to call a PHP script (which I have no control over), the script returns perfectly formed XHTML, unfortunately I only know how to read it as plaintext, so I can't insert it into my XHTML DOM tree using createnode.

I can display it using innerHTML, but as It doesn't belong to the DOM as such I can't do anything with it after that.

I hope this makes sense, I'm a backend programmer, so my clientside explanations may be lacking.

Thanks in advance
Oct 15 '08 #1
Share this Question
Share on Google+
5 Replies


acoder
Expert Mod 15k+
P: 16,027
If it's valid XHTML/XML, it should be available in responseXML. If not, when you insert it into the page using innerHTML, it should be available in the DOM.
Oct 15 '08 #2

Tarantulus
100+
P: 114
If it's valid XHTML/XML, it should be available in responseXML. If not, when you insert it into the page using innerHTML, it should be available in the DOM.
Ok, it may be my lack of understanding then, I was under the impression that innerHTML jsut kind of dumped the output and it wasn't seen by the DOM...

in which case a further question, how can I style the content inserted by innerHTML after the page has loaded?

EDIT: I see what the confusion was, I didn't know about responseXML, I was using responsetext.

thanks for the assist so far.
Oct 15 '08 #3

acoder
Expert Mod 15k+
P: 16,027
Access the element(s) and use the style property (Style object).
Oct 15 '08 #4

Tarantulus
100+
P: 114
Access the element(s) and use the style property (Style object).
Is there no way to use my existing stylesheet?

EDIT: Forget this, I've worked out my problem.

Thanks Loads
Oct 15 '08 #5

Dormilich
Expert Mod 5K+
P: 8,639
Is there no way to use my existing stylesheet?
your stylesheet applies to the xhtml document, no matter if you change it by ajax or not. as long as your rules apply to it I see no problem.

regards
Oct 15 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.