oniyi-utils-xml
Advanced tools
Comparing version 0.0.2 to 0.1.0
49
index.js
'use strict'; | ||
/** | ||
* XML NodeTypes | ||
* | ||
* http://www.w3schools.com/dom/dom_nodetype.asp | ||
* | ||
* 1 ELEMENT_NODE | ||
* 2 ATTRIBUTE_NODE | ||
* 3 TEXT_NODE | ||
* 4 CDATA_SECTION_NODE | ||
* 5 ENTITY_REFERENCE_NODE | ||
* 6 ENTITY_NODE | ||
* 7 PROCESSING_INSTRUCTION_NODE | ||
* 8 COMMENT_NODE | ||
* 9 DOCUMENT_NODE | ||
* 10 DOCUMENT_TYPE_NODE | ||
* 11 DOCUMENT_FRAGMENT_NODE | ||
* 12 NOTATION_NODE | ||
*/ | ||
var utils = require('./lib/utils'); | ||
var xmldom = require('xmldom'), | ||
DOMParser = xmldom.DOMParser, | ||
XMLSerializer = xmldom.XMLSerializer, | ||
xpath = require('xpath'); | ||
exports.parse = utils.parse; | ||
exports.selectUseNamespaces = utils.selectUseNamespaces; | ||
exports.serialize = utils.serialize; | ||
exports.select = utils.select; | ||
exports.parse = function parse(xmlString, mimeType, parserOptions) { | ||
parserOptions = parserOptions || {}; | ||
mimeType = (typeof mimeType === 'string') ? mimeType : 'text/xml'; | ||
exports.XMLParseStream = require('./lib/XMLParseStream'); | ||
exports.XMLSerializeStream = require('./lib/XMLSerializeStream'); | ||
var parser = new DOMParser(parserOptions); | ||
return parser.parseFromString(xmlString, mimeType); | ||
}; | ||
exports.selectUseNamespaces = function selectUseNamespaces(nameSpaces) { | ||
return xpath.useNamespaces(nameSpaces); | ||
}; | ||
exports.serialize = function serialize() { | ||
var serializer = new XMLSerializer(); | ||
return serializer.serializeToString.apply(serializer, Array.prototype.slice.call(arguments, 0)); | ||
}; | ||
exports.select = function select() { | ||
return xpath.select.apply(xpath, Array.prototype.slice.call(arguments, 0)); | ||
}; | ||
// function removeChildNodesByXPath(selectFn, expression, xmlDoc, callback) { | ||
@@ -49,0 +14,0 @@ // async.each(selectFn(expression, xmlDoc), function(node, iteratorCallback) { |
{ | ||
"name": "oniyi-utils-xml", | ||
"version": "0.0.2", | ||
"version": "0.1.0", | ||
"description": "utils for handling xml data", | ||
@@ -12,2 +12,3 @@ "author": { | ||
"files": [ | ||
"lib", | ||
"index.js" | ||
@@ -14,0 +15,0 @@ ], |
@@ -1,3 +0,1 @@ | ||
# [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url] | ||
> utils for handling xml data | ||
@@ -16,18 +14,19 @@ | ||
```js | ||
var oniyiUtilsXml = require('oniyi-utils-xml'); | ||
oniyiUtilsXml('Rainbow'); | ||
var xmlUtils = require('oniyi-utils-xml'); | ||
``` | ||
## Functions | ||
* parse | ||
* serialize | ||
* select | ||
* selectUseNamespaces | ||
## Streams | ||
* XMLParseStream | ||
* XMLSerializeStream | ||
## License | ||
MIT © [Benjamin Kroeger]() | ||
[npm-image]: https://badge.fury.io/js/oniyi-utils-xml.svg | ||
[npm-url]: https://npmjs.org/package/oniyi-utils-xml | ||
[travis-image]: https://travis-ci.org/benkroeger/oniyi-utils-xml.svg?branch=master | ||
[travis-url]: https://travis-ci.org/benkroeger/oniyi-utils-xml | ||
[daviddm-image]: https://david-dm.org/benkroeger/oniyi-utils-xml.svg?theme=shields.io | ||
[daviddm-url]: https://david-dm.org/benkroeger/oniyi-utils-xml |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5667
6
119
32