使用包含以下标记的Jquery xml解析:

时间:2011-12-08 11:05:23

标签: jquery xml

我有一个xml响应,其中节点是imx:IMX,当我使用jquery获取此标记的某些属性时,我得到以下错误

Syntax error, unrecognized expression: IMX
[Break On This Error] throw new Error( "Syntax error, unrecognized expression: " + msg );  in jquery_v1.7.1.js (line 4179)

我的XML

<client>
    <product>
        <nodemetadata>
            <imx:IMX xmlns:imx="http://com.abc.imx" >
                <domainservice:GatewayNodeConfig imx:id="U:pgwr9B9HEeGgJbC99YpLSQ" consolePort="21963" consoleShutdownPort="21613" domainName="D_1158162131" nodeName="N_1158162131" dbConnectivity="ID_1">
                    <address imx:id="ID_2" xsi:type="common:NodeAddress" host="panther" httpPort="21961" port="21962"/>
                    <portals>
                    <NodeRef imx:id="ID_3" xsi:type="common:NodeRef" address="ID_2" nodeName="N_1158162131"/>
                    </portals>
                </domainservice:GatewayNodeConfig>
                <domainservice:DBConnectivity imx:id="ID_1" dbEncryptedPassword="AfaFnEtrQMxkOEWRSFCQAQ%3D%3D" dbHost="fortnox" dbName="ORCL" dbPort="1521" dbType="ORACLE" dbUsername="mangla"/>
            </imx:IMX>
        </nodemetadata>
    </product>
</client>

我的代码

$(xml).find('product').each(function(){ 
    $(this).children('nodemetadata').each(function(){ 
        $(this).children('imx:IMX').each(function(){ 
            $(this).children('domainservice:GatewayNodeConfig').each(function(){ 
                alert($(this).attr('domainName'));
            });
        });
    });
});

1 个答案:

答案 0 :(得分:0)

正如Felix Kling已经指出的那样..使用\\作为逃避角色

例如:

$(this).children('imx\\:IMX').each(function(){