的Jquery:不能添加XML節點,但可以附加字體
$.get("config.xml",function(xml){
$(xml).find("config").find("images").append("<image><url>../demo/Headline/2012/12/20/0/0/A/Content/8/Web201212_P8_medium.jpg</url><name></name><redirect>none</redirect></image>");
alert ($(xml).find("config").find("images").text());
});
XML:
<config>
<images>
<central>1</central>
<random>false</random>
<width>199</width>
<height>237</height>
<image>
<url>../demo/Headline/2012/12/20/0/0/A/Content/1/Web201212_P1_medium.jpg</url>
<name></name>
<redirect>none</redirect>
</image>
<image>
<url>../demo/Headline/2012/12/20/0/0/A/Content/2/Web201212_P2_medium.jpg</url>
<name></name>
<redirect>none</redirect>
</image>
<image>
<url>../demo/Headline/2012/12/20/0/0/A/Content/3/Web201212_P3_medium.jpg</url>
<name></name>
<redirect>none</redirect>
</image>
<image>
<url>../demo/Headline/2012/12/20/0/0/A/Content/4/Web201212_P4_medium.jpg</url>
<name></name>
<redirect>none</redirect>
</image>
<image>
<url>../demo/Headline/2012/12/20/0/0/A/Content/5/Web201212_P5_medium.jpg</url>
<name></name>
<redirect>none</redirect>
</image>
<image>
<url>../demo/Headline/2012/12/20/0/0/A/Content/6/Web201212_P6_medium.jpg</url>
<name></name>
<redirect>none</redirect>
</image>
<image>
<url>../demo/Headline/2012/12/20/0/0/A/Content/7/Web201212_P7_medium.jpg</url>
<name></name>
<redirect>none</redirect>
</image>
</images>
在上面的例子中,我能夠追加字符串例如。 'abcdefg'添加到xml節點。但是,當我使用HTML標籤,例如。就像例子一樣,我不能附加任何東西?如何解決這個問題?謝謝
遺漏的類型錯誤:目標函數(J,S){返回新b.fn. init(j,s)}沒有方法'parseXML'? – user782104
試試jQuery.parseXML – Adil
對不起,結果相同 – user782104