I need to parse a well-defined XML file. I defined structures and used
err = xml.Unmarshal(byteValue, &mystruct)
It works well. But I need to detect unknown tags and attributes.
When I see an unknown tag I want to report the full tag "as-is" back to the user. The same for unknown attribute.
How I can do that in Go?
you can use xmlquery to parse XML file and extract data and without defined XML data structure, it's a XPath query package.
f, err := os.Open("../books.xml")
doc, err := xmlquery.Parse(f)
list:=xmlquery.Find(doc, "//book//author")