Thanks a lot for your reply, any particular reason of why "response" should be left out? given that is still a parent tag.
As for getting the bid attribute, any idea how to do that? El martes, 3 de abril de 2018, 19:29:41 (UTC-3), C Banning escribió: > > https://play.golang.org/p/MwpdBwvRnUP > > On Tuesday, April 3, 2018 at 2:47:49 PM UTC-6, XXX ZZZ wrote: >> >> Hello, >> >> I'm trying to parse an XML with golang but I'm having a hard time >> creating a parser for the string, in fact I couldn't even get an output >> using interface{}. >> >> package main >> >> import ( >> "fmt" >> "encoding/xml" >> ) >> >> >> type MMXML_Listing struct { >> Original_title string `xml:"title"` >> Original_desc string `xml:"description"` >> Original_domain string `xml:"displayurl"` >> Original_URL string `xml:"clickurl"` >> } >> >> type MMXML_HostProperties struct { >> Tags []MMXML_Listing `xml:"response>adverts>advert"` >> } >> const s = `<?xml version="1.0" encoding="utf-8"?><response><adverts >> results="1" search="806848020741095496" query="whatsapp" country="XX" >> platform="zzz" currency="USD" guid="FP.66.66.66.61"><advert id="0" >> provider="0" bid="1" campaign="1" copy="1" network="1" sector="0" >> ecpmi="1000"><title>AdvertTitle</title><description>AdvertSummary</description><displayurl>ClickThroughURL</displayurl><clickurl> >> http://feed.domain.net/click.ashx?sys=aaa&e=sBG08dZWyRwhRESxvC6tX6WzJWV8BdmTrS%2bTR5ER3iawNpt8CrWuXiUojalDVLd%2b0mecpq8jjsCmDIKOgWIVyMkLLh4%2f6XAsMfxC535sUJC%2fb2agNsARWsEYXrPgvu%2b9sBPCJWM6YQUuN8PWqP1k8MTFpq0XwVGgGcSs03i6VRu61q9oC6JSVpARh44Sx10YOnY1Clsm24833w3TAYm0QqPDOVLMMKqrQErT0n66okBFchacKl2EhZy64VnpzJI4xJRaL%2bkavtFnsX18b6bPl0PWJadPPz%2fZ%2fe7cpS7U7qiT74wIIPwBNkoxCBLO7xqT4E8t62OSIRpUTgMxYY4Z9REWoGZYBq%2fyox8YGTV509gknMpdzQfY9uBKEj5BZgNmzkzozVelNi0agbsdLEbWhQ%3d%3d >> </clickurl><mediatype>StandardText</mediatype></advert></adverts></response>` >> >> func main() { >> r := MMXML_HostProperties {} >> err := xml.Unmarshal([]byte(s), &r) >> if err != nil { >> panic(err) >> } >> fmt.Printf("%+v", r) >> } >> >> playground: https://play.golang.org/p/BbsrKYFPj5- >> >> Basically I want to get the elements within "advert" tag, however it >> always returns empty. Any ideas why? >> >> As for the "bid" attribute within "adverts" tag, what would be the >> appropiate approach? >> >> Thanks in advance. >> >> >> -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.