XML.js provides helper functions for XML manipulation, including conversion of documents into [JXON](https://developer.mozilla.org/en-US/docs/JXON) objects. It is built on top of [xmldom](https://www.npmjs.org/package/xmldom) & [xpath](https://www.npmjs.o
npm install xml.jsjavascript
function parse(text) { ... //-> DOMDocument
`$3
`javascript
function load(file, [convert:false]) { ... //-> DOMDocument
`$3
`javascript
function serialize(node) { ... //-> String
`$3
`javascript
function query(node, expression, resolver) { ... //-> [Node]
`####Example
`javascript
XML.query(catalog, "//book[1]");
XML.query(response, "//here:contact[1]", {"here": "http://being.here/"});
`JXON
$3
`javascript
function convert(node, [compact:true]) { ... //-> {Object}
`####Example
Given
document is the following:
`xml
Will call back tomorrow.
]]>
`
Resulting JXON object, converted with JXON.convert(document), would be:
`javascript
{
"contact": {
"firstName": "George",
"lastName": "Cartier",
"*": {
"notes": {
"*": {
"#D": "Will call back tomorrow."
}
}
}
}
}
`$3
`javascript
function compact(object) { ... //-> {Object}
`
####Example
When not compacted, previous result would be the following, which could be compacted afterwards with JXON#compact:
`javascript
{
"contact": {
"@firstName": "George",
"@lastName": "Cartier",
"children": [
{
"#TEXT": "\n "
},
{
"notes": {
"children": [
{
"#TEXT": "\n "
},
{
"#CDATA": "\n Will call back tomorrow.\n "
},
{
"#TEXT": "\n "
}
]
}
},
{
"#TEXT": "\n "
}
]
}
}
``Please have a look to the test fixtures!