Using jquery for traversing XML - problem

Using jquery for traversing XML - problem

Hi all!

I'm using jquery to traverse an XML nested in my HTML page. Don't ask why :)

I simply have a scenario when I have to deal with XML on client side a lot. So, I figured I would use jquery for traversing and manipulating this XML. Everything works perfectly fine with Firefox. But it fails for IE.

Consider this HTML:

  1. <div id = "mydiv">
  2.     <p>
            <span>
            span 1
            </span>
            <span>
            span 2
            </span>
        </p>
    </div>

    <div id= "xmldiv">
        <node>
            <subnode>
            aaa
            </subnode>
            <subnode>
            bbb
            </subnode>
        </node>
    </div>






















I realize that this HTML is invalid because of my custom tags. But like I said - this is what I have to deal with :). Unlike in the example above, I inject this XML dynamically on client side - but this is irrelevant.

This is the simplest jquery code used to select elements from DOM:

  1. $(document).ready(function() {

        alert($("#mydiv p span").length);
        alert($("#xmldiv node subnode").length);

    });





In firefox - as expected I get 2 and 2 in alert window. However the jQuery under IE only selects the valid HTML tags and completely ingores my custom XML elements in the DOM. (I get 2 and then 0) Why?