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 |
![]() | This open source module is sponsored and supported by Voxgig. |
|---|
TypeScript / JavaScript
npm install jsonic @jsonic/xmlGo
go get github.com/jsonicjs/xml/goTypeScript
import{Jsonic}from'jsonic'import{Xml}from'@jsonic/xml'constparse=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 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:
Copyright (c) 2021-2025 Richard Rodger and other contributors, MIT License.
