Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/santhosh-tekuri/dom
XML Document Object Model in Go
https://github.com/santhosh-tekuri/dom
dom go golang xml
Last synced: 4 months 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 (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-11-04T09:42:37.000Z (over 6 years ago)
- Last Synced: 2024-10-07T17:48:16.205Z (4 months ago)
- Topics: dom, go, golang, xml
- Language: Go
- Size: 17.6 KB
- Stars: 6
- Watchers: 4
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# dom
[![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)
[![GoDoc](https://godoc.org/github.com/santhosh-tekuri/dom?status.svg)](https://godoc.org/github.com/santhosh-tekuri/dom)
[![Go Report Card](https://goreportcard.com/badge/github.com/santhosh-tekuri/dom)](https://goreportcard.com/report/github.com/santhosh-tekuri/dom)
[![Build Status](https://travis-ci.org/santhosh-tekuri/dom.svg?branch=master)](https://travis-ci.org/santhosh-tekuri/dom)
[![codecov.io](https://codecov.io/github/santhosh-tekuri/dom/coverage.svg?branch=master)](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
[email protected]`
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
[email protected]```