关于xml load 文件时:The data at the root level is invalid. Line 1, position 1.
来源:互联网 发布:java全局变量命名规则 编辑:程序博客网 时间:2024/06/05 14:47
今天在读取XML时,突然遇到这问题了,
总是提示:
The data at the root level is invalid. Line 1, position 1.
-XmlDocument doc = new XmlDocument();
-doc.LoadXml(FilePath);
就是有错误,XML也是对的。
--------------------
最后终于找到错误所在了:
XmlDocument 有两个方法:
- Load(string FilePath); // 输入绝对路径,或者相对路径
-LoadXml(string XmlContent);// XmlContent 包含xml元素的串
如:
XmlDocument doc = new XmlDocument();
doc.LoadXml("<item><name>wrench</name></item>");
-------------------------------
所以,要分清楚使用。
从文件读入, 使用;
Load(@"sample.xml");
wisdom Guo
2007-11-29
- 关于xml load 文件时:The data at the root level is invalid. Line 1, position 1.
- 关于Data at the root level is invalid错误的解决方式
- firefox报错 关于 JSON.parse: unexpected end of data at line 1 column 1 of the JSON data
- iOS开发:The NIB data is invalid.
- 关于SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data错误的解决
- The meta-data is invalid or is corrupt
- 关于JSP文件运行时抛出The value for the useBean class attribute XXX is invalid异常的分析
- 集成支付宝时:JSON.parse: unexpected character at line 1 column 1 of the JSON data
- 集成支付宝时:JSON.parse: unexpected character at line 1 column 1 of the JSON data
- 'The NIB data is invalid.' foruncaught exception 'NSInternalInconsistencyException'
- The argument is invalid.
- The MAC is invalid.
- jQuery Positioning data is until the last line
- 导入新的sld时出现问题The repository root is invalid or not accessible
- Invalid character in the given encoding. Line XX, position XX.解决方法
- Invalid character in the given encoding. Line XX, position XX.解决方法
- The requested page cannot be accessed because the related configuration data for the page is invalid
- This page contains the following errors: error on line 1 at column 1: Document is empty Below is a
- 控制反转(Ioc=Inversion of Control)
- xp故障恢复控制台和它的命令
- Bean配置示例
- 無法識別的USB設備
- 在vb.net编写的应用程序中取得由MS-SQL存储过程产生的值
- 关于xml load 文件时:The data at the root level is invalid. Line 1, position 1.
- 复赠 :控制台相关问题和解决方法
- URL重写 时遇到的问题
- 多种bean--- bean命名方式
- MICROSOFT SQL 2000 数据库报7994错误,不能存储数据
- Tomcat的安装配置
- 欢迎访问我的博客 www.icfans.com/blog
- bean的实例---用构造器来实例化
- 第一篇文章