1.0.3 • Published 4 years ago

xml.one v1.0.3

Weekly downloads
1
License
ISC
Repository
github
Last release
4 years ago

XML.one

one XML-API for node & web: parse, stringify, transform, xpath

import XML from 'xml.one';                      // node.js
import XML from 'https://unpkg.com/xml.one';    // browser

XML.parse & XML.stringify work like their JSON equivalents.

let xml = XML.parse(`<tag> <subtag> text </subtag> </tag>`);
XML.stringify(xml); // -> <tag> <subtag> text </subtag> </tag>

XML.transform applies an XSL Transformation.

XML.transform(xml,your_XSL_transformation);

added xpath function to every DOMNode to facilitate xpath evaluation

let xml = XML.parse(`<a> <b> <c> <d> hello </d> <d id='2'> hi </d> </c> </b> </a>`);
xml.xpath('//b')[0].xpath('.//d[@id=2]') // -> <d> hi </d>

https://www.npmjs.com/package/xml.one