使用.NET XmlDocument對象LoadXml(string xml)行為從指定字符串加載XML過程中報了一個錯:
“=”是意外的標記。標記應為“;”。 第 1 行,位置 567。
說明: 執行當前 Web 請求期間,出現未經處理的異常。請檢查堆棧跟蹤信息,以了解有關該錯誤以及代碼中導致錯誤的出處的詳細信息。
異常詳細信息: System.Xml.XmlException: “=”是意外的標記。標記應為“;”。 第 1 行,位置 567。
源錯誤:
行 60: else if (menuType == "myc")
行 61: {
行 62: doc.LoadXml(ReturnTree(5));
行 63: } |
在網上查詢到原因是.NET在解析XML文檔時發現XML文檔中有特殊字符,如果是&特殊字符,則替換成&即可,如果是其他特殊字符,則應有其他對應替換形式,這個百度即可
***************************************************************************************************************************
參考資源地址:http://www.hierror.com/csharp/201397354.shtml
症狀:
.net解析xml的時候引發異常:“=”是意外的標記。標記應為“;”。 第 7 行,位置 80。
1 <?xml version="1.0" encoding="utf-8" ?> 2 <task> 3 <item> 4 5 <id>1</id> 6 <taskUrl>http://xiaohua.zol.com.cn/detail12/11396.html</taskUrl> 7 <listUrlRegular>http://xiaohua.zol.com.cn/list.php?z_subcate_id=0&keyword=&order=1&page={page}</listUrlRegular> 8 <startAtPage>1</startAtPage> 9 <endAtPage>168</endAtPage> 10 <listRegexExpressionPath>D:\ASPX\FJSpider\FJSpider.TaskRegularLibrary\zol\ListRegular.xml<stRegexExpressionPath> 11 <contentRegexExpressionPath>D:\ASPX\FJSpider\FJSpider.TaskRegularLibrary\zol\ContentRegular.xml</contentRegexExpressionPath> 12 <daConfigPath>D:\ASPX\FJSpider\FJSpider.TaskRegularLibrary\zol\DataAccessConfig.xml</daConfigPath> 13 <contentIsLoop>false</contentIsLoop> 14 <taskDescription>所有SQLServer錯誤信息采集</taskDescription> 15 16 </item> 17 18 19 </task>
診斷:
XML節點中有xml關鍵詞或者特殊字符,比如例子中的&
解決:
把第七行網址里面的&修改為&