Loading ...
Sorry, an error occurred while loading the content.

Problem with responseXML.documentElement on IE.

Expand Messages
  • ---
    Hi, I are new here. Working with some features of YUI I found a problem. I want to process a XML generated by php, some one like this.
    Message 1 of 8 , Apr 1 6:26 PM
    • 0 Attachment
      Hi, I are new here.

      Working with some features of YUI I found a problem.

      I want to process a XML generated by php, some one like this.

      <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
      <applications>
      <all>
      <name>All programs</name>
      <link>all_programs</link>
      <name>Recent programs</name>
      <link>recent_programs</link>
      <name>Recent Documents</name>
      <link>recent_documents</link>
      <name>Opened</name>

      <link>opened</link>
      </all>
      </applications>


      when I do it:


      function successHandler(o){
      var root = o.responseXML.documentElement;
      var appName = root.getElementsByTagName('name');

      alert(appName);
      }


      The messages on Opera and Mozilla show [object HTMLColletcion], thats
      right, but on IE 6.0 the message show NULL.

      Any idea to make it work??

      Really thanks.
    • tssha
      ... Here s the simple PHP to return the XML document:
      Message 2 of 8 , Apr 3 12:31 PM
      • 0 Attachment
        --- In ydn-javascript@yahoogroups.com, "---" <odiel@...> wrote:
        >
        > Hi, I are new here.
        >
        > Working with some features of YUI I found a problem.
        >
        > I want to process a XML generated by php, some one like this.
        >
        > <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
        > <applications>
        > <all>
        > <name>All programs</name>
        > <link>all_programs</link>
        > <name>Recent programs</name>
        > <link>recent_programs</link>
        > <name>Recent Documents</name>
        > <link>recent_documents</link>
        > <name>Opened</name>
        >
        > <link>opened</link>
        > </all>
        > </applications>
        >
        >
        > when I do it:
        >
        >
        > function successHandler(o){
        > var root = o.responseXML.documentElement;
        > var appName = root.getElementsByTagName('name');
        >
        > alert(appName);
        > }
        >
        >
        > The messages on Opera and Mozilla show [object HTMLColletcion], thats
        > right, but on IE 6.0 the message show NULL.

        Here's the simple PHP to return the XML document:

        <?php
        header('content-type: application/xml');

        $xmlData = '<?xml version="1.0" encoding="UTF-8" standalone="yes"
        ?><applications><all><name>All
        programs</name><link>all_programs</link><name>Recent
        programs</name><link>recent_programs</link><name>Recent
        Documents</name><link>recent_documents</link><name>Opened</name><link>opened</link></all></applications>';

        echo $xmlData;
        ?>

        Opera9.10 and FF1.5.0.x/FF2.0.0.3 show the value of "var appName =
        root.getElementsByTagName('name')" as [object HTMLColletcion], and IE6
        and 7 show [Object].

        Are there other relevant scripts involved in making this transaction?
        Can I have a look at the PHP you're using the output the XML document?

        Regards,
        Thomas
      • andresm1981
        Are you setting the content type correctly? Check this: http://www.quirksmode.org/blog/archives/2005/09/xmlhttp_notes_r.html .. From the link above:
        Message 3 of 8 , Apr 3 1:15 PM
        • 0 Attachment
          Are you setting the content type correctly?

          Check this:
          http://www.quirksmode.org/blog/archives/2005/09/xmlhttp_notes_r.html

          .. From the link above:

          "responseXML is only available if the server sends back an XML
          document with MIME type text/xml, and not if it sends back, for
          instance, an HTML document."

          --- In ydn-javascript@yahoogroups.com, "---" <odiel@...> wrote:
          >
          > Hi, I are new here.
          >
          > Working with some features of YUI I found a problem.
          >
          > I want to process a XML generated by php, some one like this.
          >
          > <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
          > <applications>
          > <all>
          > <name>All programs</name>
          > <link>all_programs</link>
          > <name>Recent programs</name>
          > <link>recent_programs</link>
          > <name>Recent Documents</name>
          > <link>recent_documents</link>
          > <name>Opened</name>
          >
          > <link>opened</link>
          > </all>
          > </applications>
          >
          >
          > when I do it:
          >
          >
          > function successHandler(o){
          > var root = o.responseXML.documentElement;
          > var appName = root.getElementsByTagName('name');
          >
          > alert(appName);
          > }
          >
          >
          > The messages on Opera and Mozilla show [object HTMLColletcion], thats
          > right, but on IE 6.0 the message show NULL.
          >
          > Any idea to make it work??
          >
          > Really thanks.
          >
        • plamen_gurov
          I have similar problems in both IE and FireFox after several hours research I opted for responseText and RegExp parsing.
          Message 4 of 8 , Nov 24, 2007
          • 0 Attachment
            I have similar problems in both IE and FireFox after several hours
            research I opted for responseText and RegExp parsing.

            --- In ydn-javascript@yahoogroups.com, "---" <odiel@...> wrote:
            >
            > Hi, I are new here.
            >
            > Working with some features of YUI I found a problem.
            >
            > I want to process a XML generated by php, some one like this.
            >
            > <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
            > <applications>
            > <all>
            > <name>All programs</name>
            > <link>all_programs</link>
            > <name>Recent programs</name>
            > <link>recent_programs</link>
            > <name>Recent Documents</name>
            > <link>recent_documents</link>
            > <name>Opened</name>
            >
            > <link>opened</link>
            > </all>
            > </applications>
            >
            >
            > when I do it:
            >
            >
            > function successHandler(o){
            > var root = o.responseXML.documentElement;
            > var appName = root.getElementsByTagName('name');
            >
            > alert(appName);
            > }
            >
            >
            > The messages on Opera and Mozilla show [object HTMLColletcion], thats
            > right, but on IE 6.0 the message show NULL.
            >
            > Any idea to make it work??
            >
            > Really thanks.
            >
          • tssha
            ... You shouldn t have to do this. Have a look at: http://developer.yahoo.com/yui/examples/connection/weather.html to see the desired functionality in action.
            Message 5 of 8 , Nov 26, 2007
            • 0 Attachment
              --- In ydn-javascript@yahoogroups.com, "plamen_gurov"
              <plamen_gurov@...> wrote:
              >
              > I have similar problems in both IE and FireFox after several hours
              > research I opted for responseText and RegExp parsing.

              You shouldn't have to do this. Have a look at:
              http://developer.yahoo.com/yui/examples/connection/weather.html to see
              the desired functionality in action. How does your implementation
              differ from this example?

              Regards,
              Thomas
            • plamen_gurov
              ... see ... This does not have much info in it. Here is the responseText (the whole string is one line save for the first r n that got there for unknown
              Message 6 of 8 , Nov 26, 2007
              • 0 Attachment
                --- In ydn-javascript@yahoogroups.com, "tssha" <tsha@...> wrote:
                >
                > --- In ydn-javascript@yahoogroups.com, "plamen_gurov"
                > <plamen_gurov@> wrote:
                > >
                > > I have similar problems in both IE and FireFox after several hours
                > > research I opted for responseText and RegExp parsing.
                >
                > You shouldn't have to do this. Have a look at:
                > http://developer.yahoo.com/yui/examples/connection/weather.html to
                see
                > the desired functionality in action. How does your implementation
                > differ from this example?
                >
                > Regards,
                > Thomas
                >

                This does not have much info in it. Here is the responseText (the
                whole string is one line save for the first \r\n that got there for
                unknown reason): "\r\n<?
                xml version=\"1.0\" standalone=\"yes\" ?
                ><suggestions><word>god</word><word>goad</word><word>good</word><word>
                cod</word><word>gad</word><word>got</word><word>gods</word><word>go</w
                ord><word>gold</word><word>pod</word></suggestions>"
                And I am using the same server approach that we uses successfully for
                a home-grown multi-browser AJAX soluition.
                I tried both with Content-Type "text/xml" and "application/xml".
                BTW, the server side is JBoss and a JSP is actually returning the XML.
                But parsing with RegExp isreally fast...
              • plamen_gurov
                The one thing I haven t tried is to replace the inside the XML to
                Message 7 of 8 , Nov 26, 2007
                • 0 Attachment
                  The one thing I haven't tried is to replace the \" inside the XML to '
                • plamen_gurov
                  Actually the problem turned out to be the CR NL characters in the begining of the string. The parser requires the response to start with
                  Message 8 of 8 , Nov 26, 2007
                  • 0 Attachment
                    Actually the problem turned out to be the CR NL characters in the
                    begining of the string. The parser requires the response to start with
                    <?xml ....

                    Sorry...
                  Your message has been successfully submitted and would be delivered to recipients shortly.