Using jquery to parse XML, jquery parses xml

Source: Internet
Author: User

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/
 

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.