You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Tiny in-browser xml parser. 2.6KB minified or 1.6KB minified and gzipped.
This module is not supposed to work from node.js. If you want node.js version
try something else.
usage
// If you are using a bundler like browserify/webpack. Otherwise it should// be available on the window itselfvartinyxml=require('tiny.xml')varxmlString='<?xml version="1.0" ?>'+'<items xmlns="https://foo.com">'+' <item>Foo</item>'+' <item color="green">Bar</item>'+'</items>'varparser=tinyxml(xmlString)varnodes=parser.selectNodes('item')console.log(nodes.length===2,'it found two nodes')// Nodes are actual browser elements: https://developer.mozilla.org/en-US/docs/Web/API/ElementvarfirstNode=nodes[0]console.log(firstNodeinstanceofElement,'It is instance of Element')// Since we are using standard browser API, powerful Element interface is supported:varroot=parser.selectNodes('items')[0]varall=root.querySelectorAll('item')console.log(all.length===2,'matches all item elements')vargreenNode=root.querySelector('item[color="green"]')console.log(greenNode.textContent==='Bar','picks only one green node')