Skip to content

jsonicjs/xml

Repository files navigation

@jsonic/xml

A Jsonic syntax plugin that parses XML text into a tree of elements, with support for attributes, mixed content, namespaces, entities, CDATA sections, comments, processing instructions, and DOCTYPE declarations.

The same parser is available in two languages — a TypeScript/JavaScript package on npm and a Go module:

Language Package Source
TypeScript @jsonic/xml src/xml.ts
Go github.com/jsonicjs/xml/go go/xml.go

npm version build Coverage Status Known Vulnerabilities DeepScan grade Maintainability

Voxgig This open source module is sponsored and supported by Voxgig.

Install

TypeScript / JavaScript

npm install jsonic @jsonic/xml

Go

go get github.com/jsonicjs/xml/go

Quick example

TypeScript

import { Jsonic } from 'jsonic'
import { Xml } from '@jsonic/xml'

const parse = Jsonic.make().use(Xml)

parse('<greeting lang="en">Hello, <b>world</b>!</greeting>')
// {
//   name: 'greeting', localName: 'greeting',
//   attributes: { lang: 'en' },
//   children: [ 'Hello, ',
//               { name: 'b', localName: 'b', attributes: {}, children: ['world'] },
//               '!' ]
// }

Go

import (
    jsonic "github.com/jsonicjs/jsonic/go"
    xml "github.com/jsonicjs/xml/go"
)

j := jsonic.Make()
j.UseDefaults(xml.Xml, xml.Defaults)
result, _ := j.Parse(`<greeting lang="en">Hello, <b>world</b>!</greeting>`)

Documentation

Documentation is organised by the Diataxis framework — each language guide contains a tutorial, how-to recipes, a reference section, and a short explanation of design choices:

License

Copyright (c) 2021-2025 Richard Rodger and other contributors, MIT License.

About

xml

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Generated from jsonicjs/csv