jquery 1.6.1 - selecting xml

江枫思渺然 提交于 2019-12-10 16:25:02

问题


In jquery 1.4.2 i was able to select xml residing in my html page by doing the following:

var xmlSettings = $("#xmlSettings")[0];

this is the same as:

document.getElementById("xmlSettings"); //this still works fine

In jquery 1.6.1 xmlSettings is undefined. all i did was upgrade my jquery from 1.4.2 to 1.6.1 and now this is not working.

is there a different selection that i need to do, or do i need to add a plugin?

xml in Html page:

<xml id="xmlSettings">
 <items>
        <item name="Test1">Test data 1</item>
        <item name="Test2">Test data 2</item>
        <item name="Test3">Test data 3</item>
 </items>
</xml>

thanks in advance,

[Resolved] Thanks to Felix Kling

the problem seems to be one of the following:

1) IE9 is not rendering IE8 Standards mode properly. I just recently upgraded to IE9 but my app still needs to run in IE8 Standard Mode therefore I've forced it in IIS to render in IE8 using X-UA-Compatible IE=8

2) i also updated my jquery file from 1.4.2 to 1.6.1

but it could be a combination of these things i'm not really sure anyway using normal document.getElementById("xmlSettings"); still works fine so in the mean time i'll use that but very bizarre issue. i wouldn’t be surprised if it's an IE9 issue. Or maybe i'll remain on jquery 1.4.2 for now.


回答1:


This is the real reason it's not working: a regression in jQuery 1.4.2.




回答2:


You probably don't need the [0] because an id is a singular value and doesn't return an object list like finding a class would.




回答3:


I've answered my own question as suggested by Arend

[Resolved] Thanks to Felix Kling

the problem seems to be one of the following:

1) IE9 is not rendering IE8 Standards mode properly. I just recently upgraded to IE9 but my app still needs to run in IE8 Standard Mode therefore I've forced it in IIS to render in IE8 using X-UA-Compatible IE=8. Also another thing about X-UA-Compatible rather use IE=EmulateIE8 not IE=8. But still even when you use IE=EmulateIE8 it still does not play nicely with jquery 1.6.1. Therefore its better to use IE9 standard mode which works fine, so busy converting code to be standard be compliant anyway better in the long run.

2) i also updated my jquery file from 1.4.2 to 1.6.1

but it could be a combination of these things i'm not really sure anyway using normal document.getElementById("xmlSettings"); still works fine so in the mean time i'll use that but very bizarre issue. i wouldn’t be surprised if it's an IE9 issue. Or maybe i'll remain on jquery 1.4.2 for now.



来源:https://stackoverflow.com/questions/6466262/jquery-1-6-1-selecting-xml

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!