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: 2 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 (3 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[![npm version](https://img.shields.io/npm/v/inspire-parser.svg)](https://www.npmjs.com/package/inspire-parser)
[![Circle CI](https://circleci.com/gh/sgmap-inspire/parsers/tree/master.svg?style=shield)](https://circleci.com/gh/sgmap-inspire/parsers/tree/master)
[![Coverage Status](https://coveralls.io/repos/sgmap-inspire/parsers/badge.svg?branch=master&service=github)](https://coveralls.io/github/sgmap-inspire/parsers?branch=master)
[![Dependency Status](https://david-dm.org/sgmap-inspire/parsers.svg)](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
});
```