惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

美团技术团队
罗磊的独立博客
SecWiki News
SecWiki News
The Register - Security
The Register - Security
The GitHub Blog
The GitHub Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 三生石上(FineUI控件)
S
Schneier on Security
IT之家
IT之家
博客园 - 聂微东
T
The Exploit Database - CXSecurity.com
Recorded Future
Recorded Future
大猫的无限游戏
大猫的无限游戏
Know Your Adversary
Know Your Adversary
Latest news
Latest news
Vercel News
Vercel News
G
GRAHAM CLULEY
D
DataBreaches.Net
D
Darknet – Hacking Tools, Hacker News & Cyber Security
S
SegmentFault 最新的问题
博客园_首页
雷峰网
雷峰网
T
Tenable Blog
Spread Privacy
Spread Privacy
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
酷 壳 – CoolShell
酷 壳 – CoolShell
Cisco Talos Blog
Cisco Talos Blog
V
Visual Studio Blog
J
Java Code Geeks
博客园 - Franky
The Cloudflare Blog
Apple Machine Learning Research
Apple Machine Learning Research
C
CERT Recently Published Vulnerability Notes
T
Threatpost
Google DeepMind News
Google DeepMind News
F
Fortinet All Blogs
P
Privacy International News Feed
T
Threat Research - Cisco Blogs
T
The Blog of Author Tim Ferriss
V
Vulnerabilities – Threatpost
Recent Announcements
Recent Announcements
Blog — PlanetScale
Blog — PlanetScale
Security Latest
Security Latest
U
Unit 42
M
MIT News - Artificial intelligence
Y
Y Combinator Blog
K
Kaspersky official blog
有赞技术团队
有赞技术团队
B
Blog
腾讯CDC

博客园 - rudyshen

我的自信到哪里去啦 了解一下自己 最近失业啦 XtraGrid控件3——3种GridView的属性 C#命名规范,控件、数据类型、ADO.NET等 C# 跳转语句(break,continue,goto,return,throw) Winform中通过一个字符串定位到和字符串相等ID的控件(将字符串转换成相应的控件名称) - rudyshen - 博客园 用户控件笔记<原创> 什么时候应当使用interface?什么时候应当使用abstract class? XML操作<转> 怎样从DevExpress 7.1.1升级到DevExpress 7.3.5<原创> 怎样从DevExpress 7.1.1升级到DevExpress 7.3.5<原创> (C#)利用反射动态调用类成员[转载] Net中的反射使用入门 程序集的完全限定名与动态加载程序 DevExpress 7.3.5 笔记 C#控件属性 DevExpress 组件ToolBar、PopupMenu 使用有感 转 实现QQ中消息窗体闪烁功能 转
XML笔记<原创>
rudyshen · 2008-04-06 · via 博客园 - rudyshen
XML笔记<原创>

问题一:
<Root>
     <List Name="Search">
         <Field Value="001">
              <Alias Value="张三"/>
         </Field>
     </List>
</Root> XmlDocument xmlDoc=new XmlDocument();
xmlDoc.Load(@"xml.xml");

 XmlNode xmlNode = xmlDoc.SelectSingleNode(@"Field");
MessageBox.Show(xmlNode.Name);
出错如下:

---------------------------

---------------------------
System.NullReferenceException: 未将对象引用设置到对象的实例。

   在 yaouTest.yaouQuery.simpleButton2_Click(Object sender, EventArgs e) 位置 E:\Yaousoft\code\trunk\source\yaouTest\yaouQuery.cs:行号 63
---------------------------
确定  
---------------------------
解决方案:
这是由于SelectSingleNode的xpath参数没有指定对
 XmlNode xmlNode = xmlDoc.SelectSingleNode(@"Field");
更换为
XmlNode xmlNode = xmlDoc.SelectSingleNode(@"Root/List/Field");

这样就OK啦

posted on 2008-04-06 10:35  rudyshen  阅读(273)  评论()    收藏  举报