Skip to content
forked from nbio/xml

Fork of Go encoding/xml with XML namespace prefixes

License

Notifications You must be signed in to change notification settings

FatalRabbit/xml

This branch is 8 commits behind nbio/xml:main.

Folders and files

NameName
Last commit message
Last commit date
Jul 15, 2024
Oct 12, 2021
Sep 21, 2023
Oct 12, 2021
Oct 12, 2021
Oct 12, 2021
Oct 12, 2021
Mar 8, 2024
Sep 13, 2023
May 1, 2023
Sep 13, 2023
May 4, 2023
Sep 13, 2023
Sep 13, 2023
Sep 13, 2023

Repository files navigation

encoding/xml with namespace prefixes

build status pkg.go.dev

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:

<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.org</domain:name>
                                <domain:name>go.dev</domain: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"

Notes

Because this package tracks the current [master] branch of the Go repository, only the latest stable release of Go is guaranteed to be supported. The following commits are not present in this fork to permit use under the current stable release:

About

Fork of Go encoding/xml with XML namespace prefixes

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%