// NewDecoder returns a XML decoder that filters illegal characters.
NewDecoder returns a XML decoder that filters illegal characters.
// NewDecoder returns a XML decoder that filters illegal characters .
func NewDecoder(data io.Reader) *xml.Decoder {
	decoder := xml.NewDecoder(data)
	decoder.Entity = xml.HTMLEntity
	decoder.Strict = false
	decoder.CharsetReader = func(charset string, input io.Reader) (io.Reader, error) {
		utf8Reader, err := encoding.CharsetReader(charset, input)
		if err != nil {
			return nil, err
		}
		rawData, err := ioutil.ReadAll(utf8Reader)
		if err != nil {
			return nil, fmt.Errorf("Unable to read data: %q", err)
		}
		filteredBytes := bytes.Map(filterValidXMLChar, rawData)
		return bytes.NewReader(filteredBytes), nil
	}
	return decoder
}
func NewDecoder ( data io . Reader ) * xml . Decoder { decoder := xml . NewDecoder ( data ) decoder . Entity = xml . HTMLEntity decoder . Strict = false decoder . CharsetReader = func ( charset string , input io . Reader ) ( io . Reader , error ) { utf8Reader , err := encoding . CharsetReader ( charset , input ) if err != nil { return nil , err } rawData , err := ioutil . ReadAll ( utf8Reader ) if err != nil { return nil , fmt . Errorf ( " " , err ) } filteredBytes := bytes . Map ( filterValidXMLChar , rawData ) return bytes . NewReader ( filteredBytes ) , nil } return decoder }
NewDecoder returns a XML decoder that filters illegal characters.
NewDecoder returns a XML decoder that filters illegal characters .