djf-xml

Simple javascript xml parser.
Get started
Installation
npm install djf-xml
Usage
var XmlParse = require('djf-xml')
function fixture () {
return '<service>test</service><item id="1">first</item><item id="2">second</item><user role="developer"><name>djf</name></user>'
}
var xml = XmlParse(fixture())
console.log(xml.tagValue('service'))
console.log(xml.tagValue('user', 'role'))
console.log(xml.tagValue('user').tagValue('name'))
console.log(xml.tagValue(['not', 'service']))
var itens = xml.tagGroup('item')
console.log(itens)
console.log(xml.tagValue('item', 'id'))
API Documentation
-
tagValue(tag, [attribute]) - Return tag/attribute value or new Object.
- param: tag - String or Array of tags, matching the first tag found.
- param: attribute - String.
-
tagGroup(tag) - Return array of tags.
Contributing
Running tests
npm run test
Coding style
Version
Semantic Versioning
License
MIT