Skip to content

swchen/xmltool

Repository files navigation

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

About

A XML parser for JavaScript

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published