packagemainimport("encoding/xml""fmt""io/ioutil""os")typeNamestruct{XMLNamexml.Name`xml:"DomainCheckResult"`Domainstring`xml:"Domain"`Availablestring`xml:"Available"`ErrorNostring`xml:"ErrorNo"`}typeNamesstruct{XMLNamexml.Name`xml:"CommandResponse"`Domains[]Name`xml:"DomainCheckResult"`}funcmain(){xmlFile,err:=os.Open("data.xml")iferr!=nil{fmt.Println(err)os.Exit(1)}deferxmlFile.Close()XMLdata,_:=ioutil.ReadAll(xmlFile)iferr!=nil{fmt.Println(err)os.Exit(1)}vardNamesxml.Unmarshal(XMLdata,&d)fmt.Println(d.Domains)}XMLFile:namecheap.domains.checkPHX01SBAPI01--4:001.668Output:[{{DomainCheckResult}}{{DomainCheckResult}}]
添加回答
举报
0/150
提交
取消