Hello Everybody,

i got a problem with the parsing of an XML Response.

I know i have to handle IE and FF differently
So my AjaxResponse delivers Something like

<RESPONSE>
  <RHEAD>
    <REQUESTNUMBER>38</REQUESTNUMBER>
  </RHEAD>
  <RBODY>
    <ACTION>
      <CREATELAYER>
         <NAME>DESKTOP</NAME>
          <TOOLBOX>
           <RHTML>
              <IMG src="img/toolbar/widget-icon.gif" />
          </RHTML>
         <DISPLAYNAME>Desktop anzeigen</DISPLAYNAME>
         <INFO>-1</INFO>
          </TOOLBOX>
     </CREATELAYER>
   </ACTION>
  </RBODY>
</RESPONSE>

I want do accesss the nodes by getElementsByTagNames.

Until now im Using the following script

function XML2DOM(obj)
{

        if (window.ActiveXObject)
        {
                var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
                xmlDoc.async="false";
                xmlDoc.loadXML(obj);
                if(xmlDoc.parseError.errorCode!=0)
                {
                        txt="Error Code: " +
xmlDoc.parseError.errorCode + "\n";
                        txt=txt+"Error Reason: " +
xmlDoc.parseError.reason;
                        txt=txt+"Error Line: " +
xmlDoc.parseError.line;
                        alert(txt);
                }
                else
                {
                }
        }
        else if (document.implementation &&
document.implementation.createDocument)
        {
                var parser=new DOMParser();
                var text=obj;
                var xmlDoc=parser.parseFromString(text,"text/xml");
                if (xmlDoc.documentElement.nodeName=="parsererror")
                {
                        alert(xmlDoc.documentElement.childNodes
[0].nodeValue);
                }
                else
                {
                        var toAppend = document.createElement('xml');
                        toAppend.innerHTML = obj;
                        toAppend.setAttribute('id','transferToXML');
                        document.body.appendChild(toAppend);
                        xmlDoc = document.getElementById
('transferToXML');
                        alert(xmlDoc.childNodes[0].tagName); //<--
This says "RESPONSE"
                        alert(xmlDoc.getElementsByTagName
("RESPONSE").length); //<-- but this is 0 !?
                        //document.body.removeChild
(document.getElementById('transferToXML'));
                }
        }
        return(xmlDoc);
}

IE Part is working perfectly, the FF Part won't.
Funny thing is, that i was using
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
in the Nesting page (NOT in the AjaxRequest) and it worked in FF
Changing it to
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
causes the Problem.

I was working on this for hours know, and decided to look for help by
the gurus in this forum.

Thanks in advandce
Ferion

P.S.
Please exuse my improper english. I'm not a native speaker.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to