What is invalid character entity &ccb


I’ve this playground: https://go.dev/play/p/uEpYEWaQaV0
But did not get what is the issue and why it is not working! and I’m getting the error:

invalid character entity &ccb

My code is:

package main

import (

type catalog struct {
    Id string `xml:"id"`

type price struct {
    Subtotal    int    `xml:"subtotal"`
    Currency    string `xml:"currency"`
    Total       int    `xml:"total"`
    PriceStatus string `xml:"price_status"`

type image struct {
    Url string `xml:"url"`
    Id  int    `xml:"id"`

type product struct {
    Id         int    `xml:"id"`
    RetailerId int    `xml:"retailer_id"`
    Image      image  `xml:"image"`
    Price      int    `xml:"price"`
    Currency   string `xml:"currency"`
    Name       string `xml:"name"`
    Quantity   int    `xml:"quantity"`

type order struct {
    Product product `xml:"product"`
    Catalog catalog `xml:"catalog"`
    Price   price   `xml:"price"`

type Iq struct {
    XMLName xml.Name `xml:"iq"`
    Order   order    `xml:"order"`

func main() {
    contents := `<iq from="s.whatsapp.net" id="162.120-3" type="result">
  <order creation_ts="1651703902" id="1046755402590219">

    iq := &Iq{}

    err := xml.Unmarshal([]byte(contents), &iq)
    if err != nil {
    fmt.Printf("%v\n", iq.Order)


Building on the answer from @collapsar

Despite the XML being malformed, you can still process it by creating a Decoder instance and turning off Strict mode:

d := xml.NewDecoder(bytes.NewReader([]byte(contents)))
d.Strict = false
err := d.Decode(&iq)
if err != nil {
fmt.Printf("%v\n", iq.Order)

Go Playground

For reference, see https://pkg.go.dev/encoding/xml#Decoder.

Answered By – chuckx

Answer Checked By – Robin (GoLangFix Admin)

Leave a Reply

Your email address will not be published.