Convert XML To JavaScript Object – from-xml

Category: Javascript | August 4, 2021
Author:kawanet
Views Total:35 views
Official Page:Go to website
Last Update:August 4, 2021
License:MIT

Preview:

Convert XML To JavaScript Object – from-xml

Description:

A tiny XML To JS Object converter library that works with both browser and node.js.

See Also:

How to use it:

1. Import the from-xml.js.

// Browser
<script src="dist/from-xml.min.js"></script>

// Node
const fromXML = require("from-xml").fromXML;

2. Convert an XML string to a JavaScript object.

const xml = '<xml css="script"><javascript><html>css</html></javascript></xml>'
const data = fromXML(XML);

// {...}
console.warn(data);

// => css
console.warn(data.xml.javascript.html);

// => script
console.warn(data.xml["@css"]);

You Might Be Interested In:


Leave a Reply