XML error: invalid character

Go cannot parse the correct XML file with declared objects, keep getting this error:

error: XML syntax error on line 47: invalid character and

Line <pos>&n;</pos>and entity defined as<!ENTITY n "noun (common) (futsuumeishi)">

Here is the program in Go: http://play.golang.org/p/94_60srVne

+4
source share
2 answers

, Decoder Entity. , DTD, - , xml.go; , , , , d.Entity.

( encoding/xml , , HTML. .)

, xml.Unmarshal, :

func main() {
    jmd := JMdict{}

    d := xml.NewDecoder(bytes.NewReader([]byte(str)))
    d.Entity = map[string]string{
        "n": "(noun)",
    }
    err := d.Decode(&jmd)
    if err != nil {
        fmt.Printf("error: %v", err)
        return
    }
    fmt.Println(jmd)
}

Entity , JSON.

+5

- "" , , , , "" - Strict. :

d := xml.NewDecoder(os.Stdin)
d.Strict = false            
0

All Articles