xml文档:
<?xml version="1.0"?>
<msglist>
<msg><ip>127.0.0.1</ip><time>2008-08-18 04:37:42</time><content><![CDATA[dfasfdsa]]></content></msg><msg><ip>127.0.0.1</ip><time>2008-08-18 04:37:51</time><content><![CDATA[fdsafdafdsa]]></content></msg><msg><ip>127.0.0.1</ip><time>2008-08-18 04:38:01</time><content><![CDATA[fdasfsdafdsa]]></content></msg><msg><ip>127.0.0.1</ip><time>2008-08-18 04:38:09</time><content><![CDATA[fdafdsafdsa]]></content></msg><msg><ip>127.0.0.1</ip><time>2008-08-18 04:38:17</time><content><![CDATA[fdasfdsafdsa]]></content></msg>
</msglist>
jQuery代码:
<SCRIPT. LANGUAGE="JavaScript"> <!-- $("document").ready(function(){ $.ajax({ url: "guestbook.xml", dataType: "xml", //这里注意的是应该加上这个 success: function(xml){ $(xml).find("msglist > msg").each(function(){ alert($(this).find("content").text()); }); } }) }) //--> </SCRIPT>