Question : XML in Jquery

Hi, can anyone tell me why the third line doesnt work?, and how i fix it? i need to handle xml string data.
Thanks.

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
<html>
 <head>
  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
 </head>
<script type="text/javascript">

//IT WORK
alert($('<x><r/><b><c id="1""/></b></x>').find('c').attr('id'))
alert($('<x><r/><u><c id="1""/></u></x>').find('c').attr('id'))
//IT DOESNT WORK
alert($('<x><r/><m><c id="1""/></m></x>').find('c').attr('id'))

</script>
 <body>
 </body>
</html>

Answer : XML in Jquery

Hi,

  This is a strange issue, that only effects IE (FF and Chrome worked with no issues), and seems to be related to IE XML Parse that I think JQuery may use by default.

  You can get around this by adding <div> tags around it and it will work in IE then, eg
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
<html>
 <head>
  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
 </head>
<script type="text/javascript">

//IT WORK
alert($('<x><r/><b><c id="1""/></b></x>').find('c').attr('id'))
alert($('<x><r/><u><c id="1""/></u></x>').find('c').attr('id'))
//Now this works...
alert($('<div><x><r/><m><c id="1""/></m></x></div>').find('c').attr('id'))

</script>
 <body>
 </body>
</html>
Random Solutions  
 
programming4us programming4us