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

推荐订阅源

aimingoo的专栏
aimingoo的专栏
V
V2EX
G
Google Developers Blog
F
Full Disclosure
Martin Fowler
Martin Fowler
宝玉的分享
宝玉的分享
H
Hacker News: Front Page
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
NISL@THU
NISL@THU
G
GRAHAM CLULEY
V
Vulnerabilities – Threatpost
Hacker News - Newest:
Hacker News - Newest: "LLM"
A
About on SuperTechFans
The Cloudflare Blog
C
Cisco Blogs
D
DataBreaches.Net
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Vercel News
Vercel News
P
Privacy International News Feed
Microsoft Security Blog
Microsoft Security Blog
Help Net Security
Help Net Security
Recorded Future
Recorded Future
PCI Perspectives
PCI Perspectives
S
Schneier on Security
AI
AI
N
News | PayPal Newsroom
雷峰网
雷峰网
C
Cyber Attacks, Cyber Crime and Cyber Security
P
Proofpoint News Feed
The Last Watchdog
The Last Watchdog
L
LINUX DO - 最新话题
Hugging Face - Blog
Hugging Face - Blog
Apple Machine Learning Research
Apple Machine Learning Research
Schneier on Security
Schneier on Security
S
Securelist
云风的 BLOG
云风的 BLOG
Stack Overflow Blog
Stack Overflow Blog
博客园_首页
AWS News Blog
AWS News Blog
TaoSecurity Blog
TaoSecurity Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Recent Commits to openclaw:main
Recent Commits to openclaw:main
博客园 - 三生石上(FineUI控件)
C
CXSECURITY Database RSS Feed - CXSecurity.com
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Cloudbric
Cloudbric
C
Cybersecurity and Infrastructure Security Agency CISA
Project Zero
Project Zero
C
Check Point Blog
S
Security Affairs

博客园 - epan

www.smallsocial.com 一晃眼这个blog已经丢弃两年。。。 自动调节img宽度的脚本 寻找开源的P2P视频点播系统 为什么vs2005内置Web application server中调用COM组件时正常,在IIS中运行时组件创建失败? 请教vs2005中单元测试时测试一个返回对象的方法应该怎么做? - epan - 博客园 用ASP.NET缓存提高站点性能【转载】 ADO.NET实用经验无保留曝光 (四)【转载】 ADO.NET实用经验无保留曝光 (三)【转载】 ADO.NET实用经验无保留曝光 (二)【转载】 ADO.NET实用经验无保留曝光(一)【转载】 使用MasterPage遇到的问题 - epan - 博客园 在VS.NET2003中无法新建C#项 最近迷上了淘宝,好像真的有免费的午餐一样。。。 Where to go??? 《鬼谷子》 鬼谷子本经阴符七术 《老子》 我又做了一件不可思议的事。。。
XML节点存在namespace(xmlns)的时候xpath不能正常工作
epan · 2006-08-18 · via 博客园 - epan

xml文件如下:

 1 <MODULE>
 2 <MESSAGE Type="Reply" Reference="Ref3">
 3 <PARAMETER Name="PublicReply" Type="XMLString">
 4 <MyAPI_RESULT xmlns="MyAPI">
 5 <ANSWER ID="801">
 6 <RECORDS>
 7 <ROW ForID="123456" data1="1" data2="2" data3="3"/>
 8 </RECORDS>
 9 </ANSWER>
10 </MyAPI_RESULT>
11 </PARAMETER>
12 </MESSAGE>
13 </MODULE>

如果按往常查询的话:

 XmlDocument doc = new XmlDocument();
doc.LoadXml(strXMLData);
XmlNode root 
= doc.SelectSingleNode(".//RECORDS");

root是null。

解决办法:

1 XmlDocument doc = new XmlDocument();
2 doc.LoadXml(strXMLData);
3 XmlNamespaceManager manager = new XmlNamespaceManager(doc.NameTable);
4 manager.AddNamespace("MyAPI""MyAPI");
5 XmlNode root = doc.SelectSingleNode("//MyAPI:RECORDS", manager);

加上XmlNamespaceMananger就可以正常了。