Skip to content

Commit

Permalink
Exposed parseFromDocument (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
w8r authored Aug 24, 2021
1 parent 12edaa5 commit c651516
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand All @@ -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
Expand Down
9 changes: 5 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default class WMS {

/**
* @param {String=} xmlString
* @return {Object}
* @return {Object|null}
*/
toJSON (xmlString) {
xmlString = xmlString || this._data;
Expand All @@ -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);
Expand Down

0 comments on commit c651516

Please sign in to comment.