Skip to content

santhosh-tekuri/dom

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dom

License GoDoc Go Report Card Build Status codecov.io

Package dom provides document object model for xml.

It does not strictly follow DOM interfaces, but has everything needed for xml processing library.

Example

str := `
<developer xmlns="www.jroller.com/santhosh/">
<name>Santhosh Kumar Tekuri</name>
<email>santhosh.tekuri@gmail.com</email>
</developer>
`

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:
<developer xmlns="www.jroller.com/santhosh/">
    <name>Santhosh Kumar Tekuri</name>
    <email>santhosh.tekuri@gmail.com</email>
</developer>

About

XML Document Object Model in Go

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages