Skip to content
/ goxml Public
forked from speedata/goxml

A struct base XML representation for Go

License

Notifications You must be signed in to change notification settings

mequq/goxml

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go reference documentation

Go XML

Go XML is a DOM based XML representation for Go. The entire XML file is read into a set of structs and can be accessed without keeping the source file open.

Used in https://github.com/speedata/goxpath

Sample usage

myfile.xml:

<data attrib="hello">
    <p>hello world!</p>
</data>

main.go:

package main

import (
	"fmt"
	"log"
	"os"

	"github.com/speedata/goxml"
)

func dothings() error {
	r, err := os.Open("myfile.xml")
	if err != nil {
		return err
	}
	doc, err := goxml.Parse(r)
	if err != nil {
		return err
	}
	rootElt, err := doc.Root()
	if err != nil {
		return err
	}
	fmt.Println(rootElt.Attributes()) // [attrib="hello"]
	_ = rootElt.Parent                // document node

	return nil
}

func main() {
	if err := dothings(); err != nil {
		log.Fatal(err)
	}
}

License: BSD-3-Clause License

About

A struct base XML representation for Go

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%