Converting plaintext to DOM objects

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Tarantulus
    New Member
    • May 2007
    • 114

    #1

    Converting plaintext to DOM objects

    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
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    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.

    Comment

    • Tarantulus
      New Member
      • May 2007
      • 114

      #3
      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.

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Access the element(s) and use the style property (Style object).

        Comment

        • Tarantulus
          New Member
          • May 2007
          • 114

          #5
          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

          Comment

          • Dormilich
            Recognized Expert Expert
            • Aug 2008
            • 8694

            #6
            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

            Comment

            Working...