Xmlfile. xml
CopyCode The Code is as follows: <? XML version = "1.0" encoding = "UTF-8"?>
<Msglist>
<MSG name = "11">
<ID> 1 </ID>
<Content> content1 </content>
</MSG>
<MSG name = "22">
<ID> 2 </ID>
<Content> content2 </content>
</MSG>
</Msglist>
Jqxmlfirst. aspx Copy code The Code is as follows: <% @ page Language = "C #" autoeventwireup = "true" codefile = "jqxmlfirst. aspx. cs" inherits = "jqueryxml_jqxmlfirst" %>
<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head runat = "server">
<Title> jquery getting started with XML Operations </title>
<SCRIPT type = "text/JavaScript" src = ".../JS/jquery-1.2.6.js"> </SCRIPT>
<SCRIPT type = "text/JavaScript">
$ (Function (){
$. Ajax ({
URL: "xmlfile. xml ",
Datatype: "XML ",
Error: function (XML ){
Alert ('error loading XML document '+ XML );
},
Success: function (XML ){
$ (XML). Find ("msglist> MSG"). Each (function (){
Alert ($ (this). Find ("content"). Text (); // each is executed cyclically, that is, multiple pops up.
Alert ($ (this). ATTR ("name"); // Method for retrieving attributes
});
}
})
});
</SCRIPT>
</Head>
<Body>
<Form ID = "form1" runat = "server">
<Div>
</Div>
</Form>
</Body>
</Html>