Connecting Tech Pros Worldwide Forums | Help | Site Map

Converting plaintext to DOM objects

Tarantulus's Avatar
Member
 
Join Date: May 2007
Posts: 103
#1: Oct 15 '08
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

acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#2: Oct 15 '08

re: Converting plaintext to DOM objects


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.
Tarantulus's Avatar
Member
 
Join Date: May 2007
Posts: 103
#3: Oct 15 '08

re: Converting plaintext to DOM objects


Quote:

Originally Posted by acoder

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.
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#4: Oct 15 '08

re: Converting plaintext to DOM objects


Access the element(s) and use the style property (Style object).
Tarantulus's Avatar
Member
 
Join Date: May 2007
Posts: 103
#5: Oct 15 '08

re: Converting plaintext to DOM objects


Quote:

Originally Posted by acoder

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
Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Posts: 3,664
#6: Oct 15 '08

re: Converting plaintext to DOM objects


Quote:

Originally Posted by Tarantulus

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
Reply