Parsing XML data with JavaScript is a common programming task that JavaScript can do, of course, jquery can do. Let's summarize some examples of XML parsing using jquery
The first scenario: code is as follows: <script type= "Text/javascript" > $ (document). Ready (function () { $.ajax ({ ur L: ' Http://www.test.net/cgi/test.xml ', dataType: ' xml ', success:function (data) { &NBSP ; //console.log (data); $ (data). Find ("Channel"). Find ("item"). Each (function (index, ele) { var-titles = $ (ele). Find (" Title "). Text (); var links = $ (ele). Find ("link"). text (); Console.log (titles+ '-----'); $ ("#noticecon"). Find (' ol '). Append (' <li><a href= "' +links+ '" > ' +titles+ ' </a></li > '); }); } }; }) </script> <div id= "Noticecon" > <ol> </ol> </div > second option: Code as follows: <script type= "Text/javascript" > $.get ("http:// Www.test.net/cgi/test.xml ", function (data) { $ (data). Find (' channel '). Find (' item '). Each (function (index, ele) { var titles = $ (ele). Find (' title '). Text (); var links = $ (ele). Find (' link '). text (); $ ("#noticecon"). Find (' ol '). Append (' <li><a href= "' +links+ '" > ' +titles+ ' </a></li > '); }) </script> <div id= "Noticecon" > <ol> </ol> </div> & nbsp General steps are as follows: 1. Read the XML file code as follows: $.get ("XMLFile.xml", function (XML) { $ (XML). Find ("item"). length; } ); 2. Read XML content If read XML is coming in XML file, this combination of the above point, processing as follows: code as follows: $.get ("XMLFile.xml", function (XML) { $ (XML). Find ("item"). length; }); If you read an XML string, be aware that the XML string must be surrounded by "<xml>" and "</xml>" to be resolved by the code as follows: $ ("<xml>< Root><item></item></root></xml> "). Find (" item "). length; Parsing XML content: Sample xml: Code as follows: <?xml version= "1.0" encoding= "Utf-8"?> <fields> <field name= "Name1" > <fieldname>dsname</fieldname> <datatype> character </datatype> </field> <field name= "Name2" > < fieldname>dstype</fieldname> <datatype> character </datatype> </field> </ Fields> The following is the parsing sample code: Code is as follows: $ (XML). Find ("field"). each (function () { var field = $ (this); Nbsp;var fName = field.attr ("Name");/Read Node properties var dataType = Field.find ("DataType"). Text ();//Read child node value});