Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/geodatagouv/parsers
✨Blazing fast XML parser to deal with Inspire and OGC standards ✨
https://github.com/geodatagouv/parsers
Last synced: 4 months ago
JSON representation
✨Blazing fast XML parser to deal with Inspire and OGC standards ✨
- Host: GitHub
- URL: https://github.com/geodatagouv/parsers
- Owner: geodatagouv
- License: mit
- Created: 2015-12-18T10:58:37.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2018-03-28T09:46:42.000Z (almost 7 years ago)
- Last Synced: 2024-10-06T23:36:06.178Z (5 months ago)
- Language: JavaScript
- Homepage:
- Size: 243 KB
- Stars: 1
- Watchers: 5
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-blazingly-fast - parsers - ✨Blazing fast XML parser to deal with Inspire and OGC standards ✨ (JavaScript)
README
# inspire-parser
Powerful XML parser to deal with Inspire and OGC standards[](https://www.npmjs.com/package/inspire-parser)
[](https://circleci.com/gh/sgmap-inspire/parsers/tree/master)
[](https://coveralls.io/github/sgmap-inspire/parsers?branch=master)
[](https://david-dm.org/sgmap-inspire/parsers)## Prerequisite
* [Node.js](https://nodejs.org) >= 6.0
* OR [Babel](https://babeljs.io/) for older Node.js versions + browser## Usage (CLI)
### Installation
```
npm install -g inspire-parser
```### CLI
```bash
cat metadata.xml | inspire2json
```## Usage (library)
### Installation
```
npm install inspire-parser
```### Basic
```js
const parse = require('inspire-parser').parse;const xmlString = `
Prochains passages temps réel du réseau TCL
Réseaux de transport
Services d'utilité publique et services publics
`;parse(xmlString, (err, result) => {
console.log(result.type); // print parsed element type: Record
console.log(JSON.stringify(result.body, true, 4)); // Print parsed result below
});
```Result (very basic example):
```json
{
"title": "Prochains passages temps réel du réseau TCL",
"subject": [
"Réseaux de transport",
"Services d'utilité publique et services publics"
]
}
```### Stream
```js
const fs = require('fs');
const Parser = require('inspire-parser').Parser;const parser = new Parser();
const xmlStream = fs.createReadStream(pathToXmlFile);xmlStream.pipe(parser).once('result', result => {
console.log(result.type); // print parsed element type
console.log(JSON.stringify(result.body, true, 4)); // Print parsed result in JSON
});
```