Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kamranayub/jquery-xml-helper
Allows parsing and manipulation for string-based XML in jQuery in all browsers, including IE6+
https://github.com/kamranayub/jquery-xml-helper
Last synced: 29 days ago
JSON representation
Allows parsing and manipulation for string-based XML in jQuery in all browsers, including IE6+
- Host: GitHub
- URL: https://github.com/kamranayub/jquery-xml-helper
- Owner: kamranayub
- Created: 2011-02-22T16:16:37.000Z (almost 14 years ago)
- Default Branch: master
- Last Pushed: 2011-02-25T15:52:35.000Z (almost 14 years ago)
- Last Synced: 2024-10-16T11:19:12.102Z (3 months ago)
- Language: JavaScript
- Homepage:
- Size: 107 KB
- Stars: 3
- Watchers: 4
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
jQuery XML Helper
-----------------**Requirements**
- jQuery 1.5
This small plugin will make parsing **and** manipulating XML strings/documents in browsers
much easier and work correctly.The problem with using vanilla jQuery to manipulate an XML string in browsers
is that jQuery isn't quite meant for using the XML DOM to append elements.To get around this, this plugin wraps your XML string inside of the appropriate XMLDOM
and overrides some core jQuery methods to provide support for XML manipulation.# Usage #
// Load up an XML string
var $xml = $.xml(your_string_xml);
// Find children
$xml.find("foo");
// Manipulate (can wrap new XML elements in $.xml or use plain strings)
$xml.append("");As you can see, you can use all the same jQuery methods as it is a proper jQuery object.
# XML-specific Methods #
## .xml() ##
$.xml("string").xml()
Returns the outer XML of the jQuery object. Use on the root (`$yourXmlVar.xml()`) to get the entire document
or use it on an element (`$yourXmlVar.find("child > grandchild").xml()`) to get its outer XML.## .cdata([data]) ##
// Get
$.xml("string").find("child").cdata()
// Or
$.xml("string").find("child").html()
// Set
$.xml("string").find("child").cdata("some html")
// Or
$.xml("string").find("child").html("some html")Gets or sets the CDATA for an element. It will overwrite any existing CDATA. You can also use `.html()` as another way
to get or set the same way.# Known Issues #
- FF 4 beta doesn't work
# What Seems to Work #- Browsers
- IE7, IE8, IE9
- FF 3.6
- Chrome
- Safari
- Opera
- Methods
- append, appendTo
- before, insertBefore
- insertAfter
- find
- children
- first
- text
- attr
- html# Untested #
- Complicated XML documents with namespaces (Could use xmlns jQuery plugin?)
- Methods:
- after
- prepend, prependTo
- clone
- empty, removeAll
- replaceWith, replaceAll
- wrap, wrapAll, wrapInner