我有以下结构:
type XMLProduct struct {
XMLName xml.Name `xml:"row"`
ProductId string `xml:"product_id"`
ProductName string `xml:"product_name"`
OriginalPrice string `xml:"original_price"`
BargainPrice string `xml:"bargain_price"`
TotalReviewCount int `xml:"total_review_count"`
AverageScore float64 `xml:"average_score"`
}
我使用 对其encoding/xml进行编码,然后将其显示在网页上。
该ProductName字段需要用<![CDATA[]]. 但是如果我把它写成<![CDATA[ + p.ProductName + ]]>,<and>将被翻译成<and >。
我怎样才能CDATA以最低的成本创建?