I
believe you have to use the getAttribute() method when navigating XML to get the
attribute values.
I've
heard rumors that you can use documentElement in IE as long as your document
mime type is set to 'text/xml' for the XML you're retrieving. But I don't have
an XML source I can use to test just now. :P
Has
anybody had any luck with this?
Thanks!
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]On Behalf Of Sam
Sent: Sunday, August 13, 2006 10:29 PM
To: rails-spinoffs@lists.rubyonrails.org
Subject: RE: [Rails-spinoffs] XML QuestionI've had my Ajax XML reader working for a week now. Then I hit a snag late in the game (doesn't work in IE) explained by Dean Edwards:Since request.requestXML.documentElement isn't available in IE, I'm experimenting with using the requestXML and searching the tree using getElementsByTagName.I'm confounded by not being able to read the element attributes. Here's a line of the XML:<Module name="this is a name" attr="abcde">request.requestXML.getElementsByTagName('Module')[0] // this will locate <Module but...how to I get the value of attr? It seems it should berequest.requestXML.getElementsByTagName('Module')[0].attr // but it doesn't exist...Any ideas?Sam
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Sam
Sent: Friday, July 28, 2006 1:17 PM
To: rails-spinoffs@lists.rubyonrails.org
Subject: RE: [Rails-spinoffs] XML Question... is the responseXML below available only in Mozilla? I get nada in IE.Sam-----Original Message-----I don't understand your question right, but in some ways this understanding seems to be correct.
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Kjell Bublitz
Sent: Monday, July 24, 2006 4:19 PM
To: rails-spinoffs@lists.rubyonrails.org
Subject: Re: [Rails-spinoffs] XML Question
Have you just tried to request the xml document with the ajax class and had a look into responseXML ?
Here is how i do it. (copied from my recent project):
new Ajax.Request(tplpath + 'system/workdir/blocks.xml', {
method:'get', requestHeaders:['cache-control','no-cache','pragma','no-cache'],
onComplete:function(xmlresult) {
if( xmlresult.responseXML.firstChild.nodeName == 'bloxpress') { // check if first child is as expected
Bloxpress.blocksParse(xmlresult.responseXML); // pass the responseXML to a function
} else {
var blockMenuDiv = Builder.node('div', {id:'contentmenu', style:'display:none'},['No Blocks available']);
$(blockMenuTarget).appendChild(blockMenuDiv);
Bloxpress.blocksMenu = $('contentmenu');
}
}
});
2006/7/24, Sam <[EMAIL PROTECTED] >:If this XML file isn't a DOCTYPE (not a html/body/tag document), should I expect Ajax responseXML to build out an xml-doctree or should I move on to xPath?Sam-----Original Message-----humm.. as far as i know if your server delivers an XML file as text/xml or something similar then Ajax.request will fill responseXML which contains the xml-doctree. With that you can use the common DOM functions to wade through all the data and then fill your elements as you like.
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of Kjell Bublitz
Sent: Monday, July 24, 2006 11:37 AM
To: rails-spinoffs@lists.rubyonrails.org
Subject: Re: [Rails-spinoffs] XML Question
Hope this helps.
2006/7/24, Sam <[EMAIL PROTECTED]>:I've got an XML file which is pretty well structured. I need to retrieve specific elements from that file to fill out empty HTML elements on a page.I think what I need is xPath? Or - is that overkill? Is there some easier way to locate an XML element?What I have in mind is pulling the XML file using Ajax, then xPath to get the bits I need.Am I on the right path and does prototype have an xPath capability?Sam
_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs