| From | Sent On | Attachments |
|---|---|---|
| KenLG | Oct 4, 2008 12:29 pm | |
| Adrian Lynch | Oct 6, 2008 2:08 am | |
| Alexandre Plennevaux | Oct 6, 2008 2:38 am | |
| Erik Beeson | Oct 6, 2008 2:41 am | |
| KenLG | Oct 8, 2008 6:20 pm | |
| Michael Geary | Oct 8, 2008 10:10 pm | |
| KenLG | Oct 14, 2008 10:59 pm | |
| Robert Koberg | Oct 15, 2008 5:16 am | |
| ricardobeat | Oct 15, 2008 8:35 am | |
| KenLG | Oct 15, 2008 5:46 pm |
| Subject: | [jQuery] Re: XML Parsing Question... | |
|---|---|---|
| From: | ricardobeat (rica...@gmail.com) | |
| Date: | Oct 15, 2008 8:35:41 am | |
| List: | com.googlegroups.jquery-en | |
Ajax's XMLHTTPRequest depends on ActiveX to work in IE6, you are already using it.
- ricardo
On Oct 15, 4:00 am, KenLG <ken....@gmail.com> wrote:
Because I don't want to deal with the customer service calls generated by the ActiveX objects. Plenty of people working in corporate cubbyholes get their computers locked down so that ActiveX isn't allowed to execute. Not that I really want to worry about IE6 but I can't exclude them yet. :)
And, I know it's technically not an xml parser but it's not an HTML parser either unless the underlying code only recognizes HTML tags. In a way, it seems more like an SGML parser.
Still doesn't explain why it works in some browsers and not the other (i.e. FF2 vs FF3).
kn
On Oct 8, 10:10 pm, "Michael Geary" <m....@mg.to> wrote:
Well... Really, it doesn't work *at all*. You're not using anXMLparser. It's an HTML parser. Sure, it will do some kind of passable job of parsing some kinds ofXML, sort of, in some browsers.
Why not use a realXMLparser?
function parseXML(xml) { if( window.ActiveXObject && window.GetObject ) { var dom = new ActiveXObject( 'Microsoft.XMLDOM' ); dom.loadXML(xml); return dom; } if( window.DOMParser ) return new DOMParser().parseFromString(xml, 'text/xml' ); throw new Error( 'NoXMLparser available' ); }
A quick test:
var dom = parseXML('<foo what="isit"><bar>howdy</bar></foo>'); var $dom = $(dom); console.log( $dom.find('foo').attr('what') ); // "isit" console.log( $dom.find('bar').text() ); // "howdy"
You could make it a plugin:
jQuery.parseXML = function(xml) { return jQuery( parseXML(xml) ); };
And then you can replace the first two lines of the test code above with:
var $dom = $.parseXML('<foo what="isit"><bar>howdy</bar></foo>');
-Mike
From: KenLG
It may not be supported but it works great...usually.
As far as find being case-sensitive, the weird thing is that it doesn't necessarily seem true. I could lcase the tags in theXMLbut still do the find against the mixed case element name and it still works. I had this suspicion that jquery is doing that find in a case- insensitive way.
Actually, something I forgot to try: FireFox 3 works just fine with the mixed caseXML. Weird. I guess I'll just have to deal until FF2 gets phased out.
Thanks,
kn
On Oct 6, 2:42 am, "Erik Beeson" <erik...@gmail.com> wrote:
To my knowledge,XMLparsing via the jQuery constructor
isn't supported.
See here:http://dev.jquery.com/ticket/3143
--Erik
On Sat, Oct 4, 2008 at 12:29 PM, KenLG <ken....@gmail.com> wrote:
For much of my app, I'm doing an Ajax hit to the server to grabXML. That works great.
But, in some cases, I've got too many pieces of data (unrelated) that I need to pull so I'm trying to do a simple passthrough from the server side (I'm using ASP.Net). So, I'll either output from SQL Server or hand-stitch someXMLand write it to the page.
Whenever I do this passthrough (whether it comes from SQL Server or from my own efforts), theXMLdoesn't get parsed by Jquery.
For example:
var sTestXML = '<?xmlversion="1.0"?>\r \n<EventContacts><EventContact><EventContactData>Hello</ EventContactData></EventContact></EventContacts>\r\n';
var test = $(sTestXML);
alert(test.find("EventContact").length);
will result in the alert showing zero.
Now, if I lower case some of the tags (and this will vary fromXML doc toXMLdoc but usually it's the root and object-level tags), it'll work. What's going on here?- Hide quoted text -
- Show quoted text -- Hide quoted text -
- Show quoted text -





