Answer the question
In order to leave comments, you need to log in
How to parse xml in golang?
Need to parse xml.
<?xml version="1.0" encoding="WINDOWS-1251"?>
<commandresult>
<name>abonents.list</name>
<answer>200: OK</answer>
<data>
<items>
<count>2</count>
<item>
<name>id</name>
<value>67</value>
<name>phone</name>
<value>67875667867</value>
<name>name</name>
<value>Auth</value>
</item>
<item>
<name>id</name>
<value>68</value>
<name>phone</name>
<value>67875674565</value>
<name>name</name>
<value>Auth2</value>
</item>
</items>
</data>
</commandresult>
<name>id</name>
<value>67</value>
<name>phone</name>
<value>67875667867</value>
<name>name</name>
<value>Auth</value>
type GetAbonentsResponseXml struct {
XMLName xml.Name `xml:"commandresult"`
Name string `xml:"name"`
Answer string `xml:"answer"`
Count int `xml:"data>items>count"`
Items []struct {
Name []string `xml:"name"`
Value []string `xml:"value"`
} `xml:"data>items>item"`
}
Items: [
{
Name:[id phone name]
Value:[67 67875667867 Auth]
}
]
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question