xml-twig 1.2.77 → 1.2.78

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +6 -6
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -25,7 +25,7 @@ XML documents are read either with [sax](https://www.npmjs.com/package/sax) or [
25
25
  ## Installation
26
26
 
27
27
  Install module like any other node module and optionally `node-expat`:
28
- ```
28
+ ```bash
29
29
  npm install xml-twig
30
30
 
31
31
  # and optionally
@@ -45,7 +45,7 @@ API Documentation: see [Twig](./doc/twig.md)
45
45
 
46
46
  This module is designed to read huge XML-Files. Of course, it works also well for small files. First create the Twig parser. Then create a Stream and pipe it to the parser.
47
47
 
48
- ```
48
+ ```js
49
49
  const fs = require('fs')
50
50
  const twig = require('xml-twig')
51
51
 
@@ -68,7 +68,7 @@ API Documentation: see [Twig](./doc/twig.md)
68
68
 
69
69
  If you prefer [events](https://nodejs.org/api/events.html), then use `event` property instead of `function` in handler declaration:
70
70
 
71
- ```
71
+ ```js
72
72
  const parser = twig.createParser({ tag: twig.Root, event: 'rootElement' }, { method: 'sax' })
73
73
  fs.createReadStream(`${__dirname}/bookstore.xml`).pipe(parser)
74
74
 
@@ -85,7 +85,7 @@ API Documentation: see [Twig](./doc/twig.md)
85
85
  In many cases you will purge it immediately after you have used it but in some cases you may keep the element for later use. The parser knows the element position in the XML-Tree.
86
86
 
87
87
 
88
- ```
88
+ ```js
89
89
  function bookHandler(elt) {
90
90
  console.log(`${elt.attr("category")} ${elt.name} at line ${parser.currentLine}`)
91
91
  elt.purge() // -> without `purge()` the entire XML document will be loaded into memory
@@ -125,7 +125,7 @@ API Documentation: see [Twig](./doc/twig.md)
125
125
 
126
126
  - **Read every element from XML Document**
127
127
 
128
- ```
128
+ ```js
129
129
  function anyHandler(elt) {
130
130
  console.log(`${' '.repeat(elt.level)}${elt.name} => "${elt.text ?? ''}" at line ${parser.currentLine}`)
131
131
  elt.purge() // -> without `purge()` the entire XML document will be loaded into memory
@@ -163,7 +163,7 @@ Be aware if you run methods like `elt.followingSibling()`, `elt.descendant()`, `
163
163
 
164
164
  This sample program reads the `root` element and `<ebook>` elements (include their children elements), and the branches to reach the element.
165
165
 
166
- ```
166
+ ```js
167
167
  const handle_ebook = [
168
168
  { tag: 'ebook', function: ebookHandler },
169
169
  { tag: twig.Root, function: rootHandler }
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  },
6
6
  "name": "xml-twig",
7
7
  "description": "Node module for processing huge XML documents in tree mode",
8
- "version": "1.2.77",
8
+ "version": "1.2.78",
9
9
  "main": "twig.js",
10
10
  "directories": {
11
11
  "doc": "doc"