Answer the question
In order to leave comments, you need to log in
How to parse xml with nested html?
Hello!
There is an xml like this:
<?xml version="1.0" encoding="UTF-8"?>
<test>
<title>Заголовок</tile>
<description><p>01</p><p><a href="link">Ссылка</a></p></description>
</test>
type Test struct {
Title string `xml:"title"`
Description string `xml:"description"`
}
file, err := os.Open("test.xml")
if err != nil{
fmt.Printf("Error: %v", err)
}
defer file.Close()
data, err := ioutil.ReadAll(file)
if err != nil {
fmt.Printf("Error: %v",err)
}
d := FictionBook{}
err = xml.Unmarshal(data, &d)
if err != nil {
fmt.Printf("Error: %v",err)
}
fmt.Println(d)
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