XML 文档中有错误
There is an error in XML document
当我尝试反序列化 xml 文档时出现以下异常。 Xml 文档有一个标签 url,其中 google 搜索 link 可能出现。 Google 搜索 link 包含“=”,反序列化时 xml 文档不接受它。我正在从服务器获取 xml。因此,我无法对 url 标记中存在的字符串执行任何操作。我必须为我的客户做点什么。我怎样才能克服这个问题?
<?xml version="1.0" encoding="UTF-8"?>
<response>
<status>
<code>000</code>
<message>Successfully completed</message>
</status>
<reports>
<report>
<id>9973</id>
<url>http://www.google.com/search?q=guns&client=safari&safe=active</url>
</report>
</reports>
</response>
异常:
An exception of type 'System.InvalidOperationException' occurred in System.Xml.XmlSerializer.dll but was not handled in user code
内部异常:
{"'=' is an unexpected token. The expected token is ';'. Line 136, position 53."}
您的XML无效。 URL 打破了 XML 标准。具体来说,你应该转义 &
: &
.
这是有效的 XML:
<?xml version="1.0" encoding="UTF-8"?>
<response>
<status>
<code>000</code>
<message>Successfully completed</message>
</status>
<reports>
<report>
<id>9973</id>
<url>http://www.google.com/search?q=guns&client=safari&safe=active</url>
</report>
</reports>
</response>
检查您的 XML 导出函数以确保它正确转义 URL。
当我尝试反序列化 xml 文档时出现以下异常。 Xml 文档有一个标签 url,其中 google 搜索 link 可能出现。 Google 搜索 link 包含“=”,反序列化时 xml 文档不接受它。我正在从服务器获取 xml。因此,我无法对 url 标记中存在的字符串执行任何操作。我必须为我的客户做点什么。我怎样才能克服这个问题?
<?xml version="1.0" encoding="UTF-8"?>
<response>
<status>
<code>000</code>
<message>Successfully completed</message>
</status>
<reports>
<report>
<id>9973</id>
<url>http://www.google.com/search?q=guns&client=safari&safe=active</url>
</report>
</reports>
</response>
异常:
An exception of type 'System.InvalidOperationException' occurred in System.Xml.XmlSerializer.dll but was not handled in user code
内部异常:
{"'=' is an unexpected token. The expected token is ';'. Line 136, position 53."}
您的XML无效。 URL 打破了 XML 标准。具体来说,你应该转义 &
: &
.
这是有效的 XML:
<?xml version="1.0" encoding="UTF-8"?>
<response>
<status>
<code>000</code>
<message>Successfully completed</message>
</status>
<reports>
<report>
<id>9973</id>
<url>http://www.google.com/search?q=guns&client=safari&safe=active</url>
</report>
</reports>
</response>
检查您的 XML 导出函数以确保它正确转义 URL。