xmlDOM - XML From String jQuery Plugin

Convert a String of XML to a DOM Object with jQuery

The xmlDOM jQuery plugin takes a string of XML and converts it into an XML DOM object for use with jQuery.

jQuery Plugin Methods

The xmlDOM plugin adds the following jQuery method:

  • $.xmlDOM()

Example

Here's an example of how it works

var xml = '<item><title>Hello world!</title></item>';
$.xmlDOM( xml )
    .find('item > title')
        .each(function() {
            // Alert's 'Hello world!'
            alert( $(this).text() );
        });
 

Documentation

The xmlDOM plugin provides the $.xmlDOM(xml string, error callback) method that accepts two arguments: the string to convert and an optional callback method that is triggered if an error occurs. $.xmlDOM() will return a jQuery object containing the XML DOM. Here is an example:

var xmlString = '<item><title>Hello world!</title></item>';
var $dom = $.xmlDOM(xmlString, function(error) {
    alert('A parse error occurred! ' + error);
});
$dom.find('item > string');
 There are two methods for capturing errors. The first is a callback provided at execution time. If a callback isn't provided then a xmlParseError event is triggered on the document object. You may capture and respond to the event as follows:

 $(document).bind('xmlParseError', function(event, error) {

    alert('A parse error occurred! ' + error);
});
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值