djf-xml
Simple javascript xml parser.
Get started
Installation
npm install djf-xml
Usage
var XmlParse = { return '<service>test</service><item id="1">first</item><item id="2">second</item><user role="developer"><name>djf</name></user>'} var xml = // by tagconsole // test // by tag and attributeconsole // developer // by nested tagsconsole // djf // by array of tags, matiching the first tag foundconsole // test // group of tagsvar itens = xmlconsole // ["<item id=\"1\">first</item>", "<item id=\"2\">second</item>"]console // 1
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.
- param: tag - String.
Contributing
Running tests
npm run test