xml.one

1.0.3 • Public • Published

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

Package Sidebar

Install

npm i xml.one

Weekly Downloads

4

Version

1.0.3

License

ISC

Unpacked Size

49.2 kB

Total Files

18

Last publish

Collaborators

  • maxpub