https://github.com/santhosh-tekuri/dom
XML Document Object Model in Go
https://github.com/santhosh-tekuri/dom
dom go golang xml
Last synced: about 1 year ago
JSON representation
XML Document Object Model in Go
- Host: GitHub
- URL: https://github.com/santhosh-tekuri/dom
- Owner: santhosh-tekuri
- License: bsd-3-clause
- Created: 2017-05-26T11:29:50.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2018-11-04T09:42:37.000Z (over 7 years ago)
- Last Synced: 2025-03-29T12:21:12.244Z (over 1 year ago)
- Topics: dom, go, golang, xml
- Language: Go
- Size: 17.6 KB
- Stars: 6
- Watchers: 3
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# dom
[](https://opensource.org/licenses/BSD-3-Clause)
[](https://godoc.org/github.com/santhosh-tekuri/dom)
[](https://goreportcard.com/report/github.com/santhosh-tekuri/dom)
[](https://travis-ci.org/santhosh-tekuri/dom)
[](https://codecov.io/github/santhosh-tekuri/dom?branch=master)
Package dom provides document object model for xml.
It does not strictly follow DOM interfaces, but has everything needed for xml processing library.
## Example
```go
str := `
Santhosh Kumar Tekuri
santhosh.tekuri@gmail.com
`
doc, err := dom.Unmarshal(xml.NewDecoder(strings.NewReader(str)))
if err != nil {
fmt.Println(err)
return
}
root := doc.RootElement()
fmt.Printf("rootElement: {%s}%s\n", root.URI, root.Local)
buf := new(bytes.Buffer)
if err = dom.Marshal(doc, buf); err != nil {
fmt.Println(err)
return
}
fmt.Printf("xml:\n%s", buf.String())
```
Output:
```
rootElement: {www.jroller.com/santhosh/}developer
xml:
Santhosh Kumar Tekuri
santhosh.tekuri@gmail.com
```