Latest web development tutorials

jQuery.parseXML () method

jQuery Misc Methods jQuery Misc Methods

Examples

Create a jQuery object using an XML string and get the value of the title of the node.

<P id = "someElement"> </ p> <p id = "anotherElement"> </ p> <script> $ (function () { var xml = "<rss version = ' 2.0'> <channel> <title> RSS Title </ title> </ channel> </ rss>", xmlDoc = $. parseXML ( xml ), $ Xml = $ ( xmlDoc ), $ Title = $ xml. Find ( "Title" ); // The "RSS Title" attached to #someElement $ ( "#someElement" ). Append ($ title. Text () ); // Change the title to "XML Title" $ Title. Text ( "XML Title" ); // The "XML Title" attached to #anotherElement $ ( "#anotherElement" ). Append ($ title. Text () );}) </ Script>

try it"

Definition and Usage

$ .parseXML () Function is used to parse the string to the corresponding XML documents.

Tip: This function will use the browser's built-in analytic functions to create a valid XML document that can be passed to jQuery () function to create a typical jQuery object, so be traversed or other operations.


grammar

$.parseXML( xmlString )

参数 描述
xmlString String类型 格式良好的字符串,用于解析为对应的XML文档。


jQuery Misc Methods jQuery Misc Methods