Using jquery to parse XML, jquery parses xml
This example describes how to use jquery to parse XML and share it with you for your reference. The specific method is as follows:
I. xml file structure: books. xml
<? Xml version = "1.0" encoding = "UTF-8"?> <Root> <book id = "1"> <name> extjs </name> <author> JOHN </author> <price> 88 </price> </book> <book id = "2"> <name> sharp jQuery </name> <author> Li Si </author> <price> 99 </price> </book> <book id = "3"> <name> in-depth introduction to flex </name> <author> Wang Wu </author> <price> 108 </price> </book> <book id = "4"> <name> java Programming ideology </name> <author> Qian Qi </author> <price> 128 </price> </book> </root>
Ii. Page code:
<! DOCTYPE html PUBLIC "-// W3C // dtd html 4.01 Transitional // EN" "http://www.w3.org/TR/html4/loose.dtd">
Run the following command:
Interested readers can click here to download the complete code.
JQUERY parses XML and returns html
Var xml = "the xml string"; var table = $ ("the table selector"); $ (xml ). find ("viewentry "). each (function () {var tr = $ ("<tr>"); $ (this ). find ("entrydata "). each (function () {tr. append ("<td>" + $ (this ). child ("text "). text + "</td>") ;}); table. append (tr) ;}); I have never tested it, but it is probably like this.
Jquery parses xml strings
Use ajax of jquery to set ype to xml. For details, refer to api.jquery.com/jQuery.ajax/