0.0.5 • Published 5 months ago

xmltool v0.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

xmltool

A XML parser for JavaScript

Installation

npm install xmltool

or

yarn add xmltool

Usage

import {Parser} from "xmltool";

const xml = `
<form xmlns="https://www.swchen.com/schema/form"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="https://www.swchen.com/schema/form form.xsd">

    <section margin="10"
             padding="5">
        user: <input/>
        password: <input type="password"/>
        file: <input type="file"/>
    </section>
</form>
`;

const doc = new Parser(xml).parse();

result.json

Option

new Parser(text, option)

option - Object bag of settings.

Settings supported:

  • namespace - Boolean. If true, then xml namespaces are supported. default value is false.

Unsupported

  1. This parser doesn't parse document type declaration(DTD)'s intSubset, only set the intSubset text to document type node internalSubset property.
  2. This parser doesn't normalize the attribute value. Attribute-Value Normalization

Reference

  1. XML 1.0
  2. Namespaces in XML 1.0
  3. System.Xml.Linq
  4. System.Xml
  5. sax-js A sax style parser for JS.
  6. pjxml Pure JavaScript XML parser.

License

MIT

0.0.5

5 months ago

0.0.3

1 year ago

0.0.4

1 year ago

0.0.2

2 years ago

0.0.1

2 years ago