C#读取xml为null
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了C#读取xml为null相关的知识,希望对你有一定的参考价值。
XML为:
代码为:public static string ReadXML(string path, string node, string attribute) string value = string.Empty; XmlDocument doc = new XmlDocument(); doc.Load(path); XmlNode xn = doc.SelectSingleNode(node);//这里xn为null value = (attribute.Equals("") ? xn.InnerText : xn.Attributes[attribute].Value); return value; 我调试了下doc.SelectSingleNode("/CargoTracks/CargoTrack[@ID='b13fac2d-8250-4990-a622-5eca00d3a030']")为null是这个参数有问题吗?@ID='b13fac2d-8250-4990-a622-5eca00d3a030']
以上是关于C#读取xml为null的主要内容,如果未能解决你的问题,请参考以下文章