parse-flat-xml-dict-pmb

0.1.1 • Public • Published

parse-flat-xml-dict-pmb

Parse an XML fragment that contains only a very trivial key-value structure.

API

This module exports one function:

readDict(xmlFrag[, opt])

Given an XML fragment xmlFrag of suitable structure, return a dictionary object mapping elements' names to their text content.

A suitable fragment must consist of only whitespace and/or simple elements. Simple elements have just a name and optional text content. This means they can not have: a namespace, attributes, child elements.

opts is an optional options object that supports these keys:

  • combineTexts: A function that merges non-first occurrences of an element name. It will be called with arguments (oldValue, newText, key, dict) and is expected to return the combined new value. If false-y (default), an error is thrown on encounter of a duplicate key.

Known issues

  • Needs more/better tests and docs.

 

License

ISC

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.1.1
    0
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.1.1
    0
  • 0.1.0
    0

Package Sidebar

Install

npm i parse-flat-xml-dict-pmb

Weekly Downloads

0

Version

0.1.1

License

ISC

Unpacked Size

4.65 kB

Total Files

5

Last publish

Collaborators

  • mk-pmb