John E. Jardine
john_e_jardine at spamcop.net
Tue Oct 10 01:29:21 PDT 2006
You're up late again :)
You never did send me those log files.
----- Original Message -----
From: "Shawn" <sgrover at open2space.com>
To: "CLUG PROGSIG" <clug-progsig at clug.ca>
Sent: Tuesday, October 10, 2006 10:23 AM
> With XML, the natural assumption is that you can do something like this:
> var myRequestor = getXMLHTTPrequestObj();
> . . .
> var myXML = myRequester.responseXML;
> And then use the xml elements normally.
> However, I have found that this does not work, especially with IE.
> Instead, do something like this:
> var myXML = myRequester.responseXML.getElmentsByTagName("response");
> Now, the myXML variable will represent an array of "response" elements
> (usually only one element, unless you are not requesting the root...).
> Of course "response" would correspond to whatever XML tag names you are
> Using this technique - getElementsByTagName() or getElementById() -
> works fine in IE and FF. In IE, it eliminates half the response
> problems. (This threw me for about a week until I noticed the subtle
> difference in approaches...)
> Nick Wiltshire wrote:
>> though I can't do the most trivial thing.
>> I'm attempting to write a (reasonably) generic function to take XML
>> from the XMLHttpRequest object and use DOM functions to insert it. Sounds
>> easy, right? :)
>> The XML I am parsing is actually XHTML wrapped in proper XML fashion. It
>> not an entire XHTML document, but a fragment (specifically a div) which I
>> to append to the
>> page. I have validated the XML so I know that's not my issue.
>> But, I'm stuck. For some reason my function will only return text and
>> nodes and I can't figure out why. It traverses the XML tree completely &
>> correctly, but won't return the node unless it's text, or incorrectly
>> returns a text node, I can't figure out which. However, the final
>> does return a div element, which is the desired behaviour. The returned
>> element is completely empty.
>> Here's my function. The error_handler is for later consideration.
>> function XML2DOM(xml_obj, error_handler)
>> var dom_obj = false;
>> var child_node;
>> var child;
>> for(i in xml_obj.childNodes)
>> child_node = xml_obj.childNodes[i];
>> case 1:
>> dom_obj =
>> child = XML2DOM(child_node,
>> case 3:
>> dom_obj =
>> case 2:
>> case 4:
>> case 5:
>> case 6:
>> case 7:
>> case 8:
>> case 9:
>> case 10:
>> case 11:
>> case 12:
>> alert("Warning: XML2DOM encountered an
>> nodeType: " +
>> return dom_obj;
>> Hopefully that's enough detail. This function is a long way from
>> and may even be plain dumb, but I want the very basic functionality
>> The warning isn't put in the default switch case section because there's
>> bunch of undefined nodes, dunno what that's about.
> clug-progsig mailing list
> clug-progsig at clug.ca
More information about the clug-progsig