xmljs

A small and simple package which can traverse a XML document

  • xmljs

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
xmljs
0.3.27 years ago9 years agoMinified + gzip package size for xmljs in KB

Readme

Build Status A small and simple package which can traverse a XML document. Uses sax-js to parse xml. The goal of the package is a easy way to navigate and search through xml documents. This package makes is easier to extract data from XML documents. Example: ```js var XmlParser = require("xmljs"); var fs = require("fs"); var p = new XmlParser({ strict: true }); var xml = fs.readFileSync("./SOAP1.xml"); // XML in the examples direct var xmlNode = p.parseString(xml, function(err, xmlNode) {
if(err) {
console.error(err);
return;
}
var nodes = xmlNode.path(["Envelope", "Body", "GetstockpriceResponse", "Price"], true);
console.log(nodes.map(function(n) { return n.text; }));
}); ``` SOAP1.xml ```xml
<m:GetStockPriceResponse>
<m:Price>34.5</m:Price>
<m:Price>30.4</m:Price>
</m:GetStockPriceResponse>
```