System.XML.XmlException:''是意外令牌.预期令牌为“;" [英] System.XML.XmlException: ' ' is an unexpected token. The expected token is ';'

查看:249
本文介绍了System.XML.XmlException:''是意外令牌.预期令牌为“;"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个HTML表单,我正在尝试使用XDocument.Load加载,并且收到以下错误:

I have an HTML form that i'm trying to load using XDocument.Load, and i'm receiving the following error:

' ' is an unexpected token. The expected token is ';'. Line 1257, position 66.
   at System.Xml.XmlTextReaderImpl.Throw(Exception e)

代码仅调用以下内容:

XDocument xmlDoc = XDocument.Load(pageData.Stream);

pageData是来自另一个系统的自定义对象,它正在吐出数据流.我已经将xml导出回字符串,看起来还不错.

pageData is a custom object from another system, that is spitting out a datastream. I've had it export the xml back out to a string, and it looks fine.

当我检查HTML上的该行时,它只是一个元素的结束标记. xml异常给出的行/位置的可靠性如何?我只是将表单的源转储到notepad ++中进行验证,但我看不到会有问题.

When i check that line on the HTML, it's just a closing tag for an element. How reliable is the line/position given by the xml exception? I'm just dumping the source of the form into notepad++ for validation, and i can't see that it would be an issue.

以下是错误前后的前几行.我已经标记了错误行.

The following is the first few lines before and after the error. I've marked the error line.

                                        </p>
                        </td>
                    </tr>
                </table>

            </td>
        </tr>  <----Error Line
        <tr>
            <td>
                <div id="BusinessJustificationForm">
                    <table id="BusinessJustificationTable">
                        <tr>
                            <td class="seperator" colspan="7">

推荐答案

此问题是由名称中包含空格的名称"属性引起的.当我完成整个工作并解决了该问题后,便能够将HTML加载为XML文档.

This issue was caused by a "Name" attribute having a name containing spaces. Once i went through the whole thing and resolved that, I was able to load the HTML as an XML document.

这篇关于System.XML.XmlException:''是意外令牌.预期令牌为“;"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆