Example #1
0
func main() {
	w := csv.NewWriter(os.Stdout)
	defer w.Flush() // Don't forget to flush at the end.

	// Parse Person file.
	handler := TagHandler{W: w}
	if err := xmlstream.Parse(os.Stdin, &handler, 0, Speech{}); err != nil {
		panic(fmt.Sprint("Error parsing the file:", err))
	}
}
Example #2
0
func main() {
	// Open Person file.
	personFile, err := os.Open("people.xml")
	if err != nil {
		panic(fmt.Sprint("Error opening the file:", err))
	}
	defer personFile.Close()

	// Parse Person file.
	handler := TagHandler{}
	err = xmlstream.Parse(personFile, &handler, 0, Person{})
	if err != nil {
		panic(fmt.Sprint("Error parsing the file:", err))
	}
}