"golang parsing xml" Code Answer's
You're definitely familiar with the best coding language Go that developers use to develop their projects and they get all their queries like "golang parsing xml" answered properly. Developers are finding an appropriate answer about golang parsing xml related to the Go coding language. By visiting this online portal developers get answers concerning Go codes question like golang parsing xml. Enter your desired code related query in the search bar and get every piece of information about Go code related question on golang parsing xml.
golang parsing xml
package main
import (
"encoding/json"
"encoding/xml"
"fmt"
)
type Data struct {
XMLName xml.Name `xml:"data" json:"-"`
PersonList []Person `xml:"person" json:"people"`
}
type Person struct {
XMLName xml.Name `xml:"person" json:"-"`
Firstname string `xml:"firstname" json:"firstname"`
Lastname string `xml:"lastname" json:"lastname"`
Address *Address `xml:"address" json:"address,omitempty"`
}
type Address struct {
City string `xml:"city" json:"city,omitempty"`
State string `xml:"state" json:"state,omitempty"`
}
func main() {
rawXmlData := "<data><person><firstname>Nic</firstname><lastname>Raboy</lastname><address><city>San Francisco</city><state>CA</state></address></person><person><firstname>Maria</firstname><lastname>Raboy</lastname></person></data>"
var data Data
xml.Unmarshal([]byte(rawXmlData), &data)
jsonData, _ := json.Marshal(data)
fmt.Println(string(jsonData))
}
Source: tutorialedge.net
All those coders who are working on the Go based application and are stuck on golang parsing xml can get a collection of related answers to their query. Programmers need to enter their query on golang parsing xml related to Go code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about golang parsing xml for the programmers working on Go code while coding their module. Coders are also allowed to rectify already present answers of golang parsing xml while working on the Go language code. Developers can add up suggestions if they deem fit any other answer relating to "golang parsing xml". Visit this developer's friendly online web community, CodeProZone, and get your queries like golang parsing xml resolved professionally and stay updated to the latest Go updates.