Skip to content

laubstein/xmlQuery

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

xmlQuery

Javascript XML manipulation inspired on jQuery.

Why?

When trying to manipulate XML data using jQuery, I realized that all the elements and attributes are turned into lower-case and, in some cases, the code do not work well on IE.

Supported methods

append (value)Append an element
attr (name, [value])Get os set an attribute
clone ([deep])Clone the set of elements
eq (idx)Returns the element at nth position
find (elementName)Returns the elements with the specified name
first ()Returns the first element in the set
last ()Returns the last element in the set
serialize ()Returns the serialized xml
size ()Returns the number of elements in the set

Example

var myXMLData = '<root><myData dataType="Boolean">True</myData></root>',
    myXMLQuery = $X(myXMLData);
console.log('Serialized XML: ' + myXMLQuery.serialize());
// returns: Serialized XML: <root><myData dataType="Boolean">True</myData></root>
console.log('Attribute: ' + myXMLQuery.find('myData').attr('dataType'));
// returns: Attribute: Boolean

Check the test results


Created by Thiago Laubstein.

About

Javascript XML manipulation inspired on jQuery.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published