初学XML,遇到读取问题
Dim doc As New XmlDocument
Dim fr As String = Server.MapPath("list1.xml")
doc.LoadXml(fr)
Dim i = 0
Do While i < doc.DocumentElement.ChildNodes.Count - 1
Dim s As String
s = doc.DocumentElement.ChildNodes.Item(i).Value
MsgBox(s)
i = i + 1
Loop
XML是
<?xml version="1.0" encoding="GB2312"?>
<languagePack>
<hot.aspx>
<html_title>热点新闻</html_title>
<remark_num_1>(共有评论</remark_num_1>
<remark_num_2>个)</remark_num_2>
</hot.aspx>
<imgindex.aspx>
<html_title>图片新闻</html_title>
<more>更多</more>
<img_news>图片新闻...</img_news>
</imgindex.aspx>
<js.aspx>
<news_unit>篇</news_unit>
</js.aspx>
<list.aspx>
<title_topic> 专题新闻</title_topic>
</list.aspx>
</languagePack>
为什么我在doc.LoadXml(fr)这句就发生错误
“/WebApplication1”应用程序中的服务器错误。
--------------------------------------------------------------------------------
根级别上的数据无效。 行 1,位置 1。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.Xml.XmlException: 根级别上的数据无效。 行 1,位置 1。
源错误:
行 48: Dim doc As New XmlDocument
行 49: Dim fr As String = Server.MapPath("list1.xml")
行 50: doc.LoadXml(fr)
不知为什么