The data at the root level is invalid. Line 1, position 1.

简介: The data at the root level is invalid. Line 1, position 1.

The data at the root level is invalid. Line 1, position 1.


C#, 读取xml文件中节点数量


int nodeCount = 0;
                        XmlDocument doc = new XmlDocument();
                        doc.Load(file.FullName);
                        //获得根节点
                        XmlNode rootNode = doc.DocumentElement;
                        //在根节点中寻找节点
                        foreach (XmlNode node in rootNode.ChildNodes)
                        {
                            //找到对应的节点
                            if (node.Name == "url")
                            {
                                nodeCount = nodeCount + 1;
                            }
                        }


今天在读取XML时,突然遇到这问题了,


总是提示:


The data at the root level is invalid. Line 1, position 1.


-XmlDocument doc = new XmlDocument();


-doc.LoadXml(FilePath);


就是有错误,XML也是对的。


报错就改成:


doc.Load(file.FullName);
目录
相关文章
|
调度 索引
NR PUCCH(四) UL data operation
UE 在connected mode 需要实时和网络进行上下行通信,在UE有UL data要发送但是没有UL grant时,就需要向网络端发送SR请求资源,网络收到SR就会在激活的BWP上发送 UL DCI给UE,UE 根据UL DCI 信息 获得UL grant ,然后在PUSCH对应的资源上就可以发送UL data给网络,最后网络端通过HARQ 过程指示是否有收到对应的data。这是UL data 的基本流程,下面通过实际log分别看下UL data operation的各个过程。
|
6月前
Transparent Data Encryption Data Dynamic and Data Dictionary Views You can query a set of dynamic and data dictionary views to find more information about Transparent Data Encryption (TDE) data.
Transparent Data Encryption Data Dynamic and Data Dictionary Views You can query a set of dynamic and data dictionary views to find more information about Transparent Data Encryption (TDE) data.
53 2
|
2月前
|
Docker 容器
ADD failed: file not found in build context or excluded by .dockerignore: stat irap_rule_center: fil
ADD failed: file not found in build context or excluded by .dockerignore: stat irap_rule_center: fil
|
关系型数据库 MySQL 数据库
MySQL新增字段报错:ERROR 1118 -- Row size too large. The maximum row size for the used table type
MySQL新增字段报错:ERROR 1118 -- Row size too large. The maximum row size for the used table type
1664 0
|
6月前
|
存储
tracker_query_storage fail, error no: 28, error info: No space left on device
tracker_query_storage fail, error no: 28, error info: No space left on device
150 0
|
Java 开发工具 git
解决Error running XXXApplicationCommand line is too long.报错
解决Error running XXXApplicationCommand line is too long.报错
|
6月前
|
Perl
报错:error Parsing error: x-invalid-end-tag
报错:error Parsing error: x-invalid-end-tag
125 0
成功解决absl.flags._exceptions.UnrecognizedFlagError: Unknown command line flag 'data_format'
成功解决absl.flags._exceptions.UnrecognizedFlagError: Unknown command line flag 'data_format'
|
程序员 算法框架/工具 Caffe
解决办法:error: 'size_t' does not name a type、unknown type name 'size_t'
解决办法:error: 'size_t' does not name a type、unknown type name 'size_t'
718 0