0

I have following XML in this.treeSpec variable.

<root>
    <item id="9PQ0" pathId="08Z" specId="9PQ0" rel="MainRequest">
        <content>
            <name>ABC</name>
        </content>
    <item id="9PQ02" pathId="08Z2X" specId="9PQ0" rel="property">
        <content>
            <name>ABC1</name>
        </content>
    <item id="9PQ02" pathId="08Z2" specId="" ruleId="CYZ3F7WM861" rel="E" >
        <content>
            <name>ABC2</name>
        </content>
    </item>

To get first item ID I am using below code.

var rootNode = $(this.treeSpec).find("item").first();
var rootId = rootNode.attr("id");

It works perfectly in Chrome and Mozilla but it is not working in IE.

Can any one tell me how can we write code to work in IE as well.

4

1 回答 1

0

这可能不是实际的解决方案,但尝试将您的 xml 包装在 div 之类的元素中,然后尝试查找,例如:

$("<div>" + this.treeSpec + "</div>").find("item")...

希望能帮助到你

于 2012-04-30T09:21:40.007 回答