diff --git a/README.md b/README.md index 8d049af..e9d405f 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Parses [WMS](http://en.wikipedia.org/wiki/Web_Map_Service) capabilities XML form ## Usage -### Browserify +### ES ``` npm install wms-capabilities --save ``` @@ -17,6 +17,8 @@ import WMSCapabilities from 'wms-capabilities'; new WMSCapabilities().parse(xmlString); //or new WMSCapabilities(xmlString).toJSON(); +// or +new WMSCapabilities().readFromDocument(xmldoc); ``` ### Browser ```html diff --git a/src/index.js b/src/index.js index 0bf2d19..11810b8 100644 --- a/src/index.js +++ b/src/index.js @@ -42,7 +42,7 @@ export default class WMS { /** * @param {String=} xmlString - * @return {Object} + * @return {Object|null} */ toJSON (xmlString) { xmlString = xmlString || this._data; @@ -51,16 +51,17 @@ export default class WMS { /** * @return {String} xml + * @return {Object|null} */ parse (xmlString) { - return this._readFromDocument(this._parser.toDocument(xmlString)); + return this.readFromDocument(this._parser.toDocument(xmlString)); } /** * @param {Document} doc - * @return {Object} + * @return {Object|null} */ - _readFromDocument (doc) { + readFromDocument (doc) { for (let node = doc.firstChild; node; node = node.nextSibling) { if (node.nodeType == nodeTypes.ELEMENT) { return this.readFromNode(node);