Go encoding/xml package that improves support for XML namespaces

Related tags

xml
Overview

encoding/xml with namespaces

This is a fork of the Go encoding/xml package that improves support for XML namespaces, kept in sync with golang/go#48641.

It allows round-trip unmarshaling/marshaling with explicit namespace prefixes. For example, this can be unmarshalled and re-marshalled into this precise XML:

golang.org go.dev ">
<epp xmlns="urn:ietf:params:xml:ns:epp-1.0">
        <command>
                <check>
                        <domain:check xmlns:domain="urn:ietf:params:xml:ns:domain-1.0">
                                <domain:name>golang.orgdomain:name>
                                <domain:name>go.devdomain:name>
                        domain:check>
                check>
        command>
epp>

For marshaling, a preferred namespace prefix can now be specified in a struct tag or XMLName value by prefixing the local name:

xml:"urn:ietf:params:xml:ns:domain-1.0 domain:check"

Name-spaced tag and attribute names are now strictly parsed and will fail with an error if any are malformed, such as having a leading or trailing colon, or more than 1 colon.

An example playground that would be fixed with this package:

https://play.golang.org/p/-6Ee8tcLl2L

Usage

// Instead of "encoding/xml"
import "github.com/nbio/xml"

Development

To ease keeping this code in sync with a fork of Go, this repository contains a go.mod file in vendor/go/src that declares itself as the std package. This package must be tested from that directory:

cd vendor/go/src && go test -v ./encoding/xml
Owner
nb.io
nb.io
Go encoding/xml package that improves support for XML namespaces

encoding/xml with namespaces This is a fork of the Go encoding/xml package that improves support for XML namespaces, kept in sync with golang/go#48641

nb.io 3 Oct 13, 2021
Extract data or evaluate value from HTML/XML documents using XPath

xquery NOTE: This package is deprecated. Recommends use htmlquery and xmlquery package, get latest version to fixed some issues. Overview Golang packa

null 153 Sep 25, 2021
xmlwriter is a pure-Go library providing procedural XML generation based on libxml2's xmlwriter module

xmlwriter xmlwriter is a pure-Go library providing a procedural XML generation API based on libxml2's xmlwriter module. The package is extensively doc

Blake Williams 20 Jul 29, 2021
XML to MAP converter written Golang

xml2map XML to MAP converter written Golang Sometimes there is a need for the representation of previously unknown structures. Such a universal repres

Babiv Sergey 35 Oct 17, 2021
XPath package for Golang, supports HTML, XML, JSON document query.

XPath XPath is Go package provides selecting nodes from XML, HTML or other documents using XPath expression. Implementation htmlquery - an XPath query

null 424 Oct 21, 2021
A simple evaluator for arithmetic integer expressions.

The expr package provides a simple evaluator for arithmetic integer expressions. The syntax and operations are the same as in Go. Operands are the nat

Rob Pike 72 Oct 14, 2021