ITeye博客

cdata 和 xml xmlParseEntityRef: no name 错误

夜鸣猪 · 2013-05-04 00:24 · Ruby On Rails · 编程语言 · Markdown

Problem: An XML parser returns the error “xmlParseEntityRef: no name”

Cause: There is a stray ‘&’ (ampersand character) somewhere in the XML text eg. some text & some more text

Solution: Solution 1: Remove the ampersand. Solution 2: Encode the ampersand (that is replace the ‘&’ character with ‘&’ ). Remember to Decode when reading the XML text. Solution 3: Use CDATA sections (text inside a CDATA section will be ignored by the parser.) eg. <!]>

Note: ‘&’ ‘<' '>‘ will all give problems if not handled correctly.

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。