xmljs
A small and simple package which can traverse a XML document
Last updated 5 years ago by blackshadev .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install xmljs 
SYNC missed versions from official npm registry.

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:

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 version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">

  <soap:Body xmlns:m="http://www.example.org/stock">
    <m:GetStockPriceResponse>
      <m:Price>34.5</m:Price>
      <m:Price>30.4</m:Price>
    </m:GetStockPriceResponse>
  </soap:Body>

</soap:Envelope>

Current Tags

  • 0.3.2                                ...           latest (4 years ago)

8 Versions

  • 0.3.2                                ...           4 years ago
  • 0.3.1                                ...           5 years ago
  • 0.3.0                                ...           5 years ago
  • 0.2.4                                ...           5 years ago
  • 0.2.3                                ...           5 years ago
  • 0.2.1                                ...           5 years ago
  • 0.2.0                                ...           5 years ago
  • 0.1.0                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 2
Last Day 0
Last Week 1
Last Month 1
Dependencies (1)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |