JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 800337
  • Score
    100M100P100Q188288F
  • License MIT

Parse a XML string into a proprietary syntax tree

Package Exports

  • xml-parser-xo

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (xml-parser-xo) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

xml-parser-xo

XML parser based on xml-parser.

Travis CI status

NPM

Installation

$ npm install xml-parser-xo

Example

JavaScript:

var parse = require('xml-parser-xo');

var xml = `<?xml version="1.0" encoding="utf-8"?>
<!-- Load the stylesheet -->
<?xml-stylesheet href="foo.xsl" type="text/xsl" ?>
<!DOCTYPE foo SYSTEM "foo.dtd">
<foo><![CDATA[some text]]> content</foo>`;

console.log(parse(xml));

Output:

{
    "declaration": {
        "type": "ProcessingInstruction",
        "attributes": {"version": "1.0", "encoding": "utf-8"}
    },
    "root": {
        "type": "Element",
        "name": "foo",
        "attributes": {},
        "children": [
            {"type": "CDATA", "content": "<![CDATA[some text]]>"},
            {"type": "Text", "content": " content"}
        ]
    },
    "children": [
        {"type": "Comment", "content": "<!-- Load the stylesheet -->"},
        {"type": "ProcessingInstruction", "attributes": {"href": "foo.xsl", "type": "text/xsl"}},
        {"type": "DocumentType", "content": "<!DOCTYPE foo SYSTEM \"foo.dtd\">"},
        {
            "type": "Element",
            "name": "foo",
            "attributes": {},
            "children": [
                {"type": "CDATA", "content": "<![CDATA[some text]]>"},
                {"type": "Text", "content": " content"}
            ]
        }
    ]
}

License

MIT