Home > Web Front-end > JS Tutorial > body text

Description of jquery's method of parsing XML strings and XML files_jquery

WBOY
Release: 2016-05-16 16:58:48
Original
989 people have browsed it

1. Read XML string:
For example:

Copy code The code is as follows :

$(document).ready(function(){

var xml = "liublchencp< ;/root>";
//var xml="

100
"; // You can also directly identify Table
var obj = $(xml).find("record");
});


Note: Be sure to wrap a layer of xml outside, so that jquery In order to be recognized, there also needs to be a root node in the xml, which is root or something else that can be customized.

2. Read the XML file
For example:

Copy the code The code is as follows:

$(document).ready(function(){
$.get('mydata.xml',function(xml)
{
$(xml).find( "book").each(function(){
var xmlAttr=$(this).attr("Attribute");
var xmlText=$(this).fint("node").text() ;
});
});
});
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template