xml.one

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

Usage no npm install needed!

<script type="module">
  import xmlOne from 'https://cdn.skypack.dev/xml.one';
</script>

README

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