Getting started with jquery XML operations

Source: Internet
Author: User

Xmlfile. xml

  1. <? XML version = "1.0" encoding = "UTF-8"?>
  2. <Msglist>
  3. <MSG name = "11">
  4. <ID> 1 </ID>
  5. <Content> content1 </content>
  6. </MSG>
  7. <MSG name = "22">
  8. <ID> 2 </ID>
  9. <Content> content2 </content>
  10. </MSG>
  11. </Msglist>

Jqxmlfirst. aspx

  1. <% @ Page Language = "C #" autoeventwireup = "true" codefile = "jqxmlfirst. aspx. cs" inherits = "jqueryxml_jqxmlfirst" %>
  2. <! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <HTML xmlns = "http://www.w3.org/1999/xhtml">
  4. <Head runat = "server">
  5. <Title> jquery getting started with XML Operations </title>
  6. <SCRIPT type = "text/JavaScript" src = ".../JS/jquery-1.2.6.js"> </SCRIPT>
  7. <SCRIPT type = "text/JavaScript">
  8. $ (Function (){
  9. $. Ajax ({
  10. URL: "xmlfile. xml ",
  11. Datatype: "XML ",
  12. Error: function (XML ){
  13. Alert ('error loading XML document '+ XML );
  14. },
  15. Success: function (XML ){
  16. $ (XML). Find ("msglist> MSG"). Each (function (){
  17. Alert ($ (this). Find ("content"). Text (); // each is executed cyclically, that is, multiple pops up.
  18. Alert ($ (this). ATTR ("name"); // Method for retrieving attributes
  19. });
  20. }
  21. })
  22. });
  23. </SCRIPT>
  24. </Head>
  25. <Body>
  26. <Form ID = "form1" runat = "server">
  27. <Div>
  28. </Div>
  29. </Form>
  30. </Body>
  31. </Html>

End

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.