Skip to content

Commit 16fb9a5

Browse files
authored
Create README.md
1 parent 681efe4 commit 16fb9a5

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# xml [![GoDoc](https://godoc.org/github.com/m29h/xml?status.svg)](https://godoc.org/github.com/m29h/xml) [![Tests](https://github.com/m29h/xml/actions/workflows/test.yml/badge.svg)](https://github.com/m29h/xml/actions/workflows/test.yml) [![Coverage Status](https://coveralls.io/repos/github/m29h/xml/badge.svg)](https://coveralls.io/github/m29h/xml) [![Go Report Card](https://goreportcard.com/badge/github.com/m29h/xml)](https://goreportcard.com/report/github.com/m29h/xml)
2+
3+
Package `github.com/m29h/xml` implements a XML 1.0 marshaler that is a drop in `encoding/xml` replacement maintaining full interface compatibility to it but aims to producing [C14N Exclusive XML Canonicalization](https://www.w3.org/TR/xml-exc-c14n/) compatible byte sequences. This includes sorting of all rendered element attributes as per the C14N-XML spec.
4+
5+
## Example
6+
A Struct defined in the normal way as known from `encoding/xml`
7+
8+
```go
9+
type Person struct {
10+
XMLName xml.Name `xml:"http://example.com/ns1 person"`
11+
Name string `xml:"name"`
12+
Phone string `xml:"http://example.com/ns2 phone,omitempty"`
13+
}
14+
```
15+
is marshaled to
16+
```xml
17+
<ns1:person xmlns:ns1="http://example.com/ns1">
18+
<ns1:name>Foo</ns1:name>
19+
<ns2:phone xmlns:ns2="http://example.com/ns2">123</ns2:phone>
20+
</ns1:person>
21+
```

0 commit comments

Comments
 (0)