c# public static bool IsSelectNode(string xmlPath,string node){XmlDocument xmlDoc = new XmlDocument();xmlDoc.Load(xmlPath);XmlNode result = xmlDoc.SelectSingleNode(@"//" + node);return result = null;//就这行}
来源:学生作业帮助网 编辑:作业帮 时间:2024/06/30 02:21:45
![c# public static bool IsSelectNode(string xmlPath,string node){XmlDocument xmlDoc = new XmlDocument();xmlDoc.Load(xmlPath);XmlNode result = xmlDoc.SelectSingleNode(@](/uploads/image/z/11192207-23-7.jpg?t=c%23+public+static+bool+IsSelectNode%28string+xmlPath%2Cstring+node%29%7BXmlDocument+xmlDoc+%3D+new+XmlDocument%28%29%3BxmlDoc.Load%28xmlPath%29%3BXmlNode+result+%3D+xmlDoc.SelectSingleNode%28%40%22%2F%2F%22+%2B+node%29%3Breturn+result+%3D+null%3B%2F%2F%E5%B0%B1%E8%BF%99%E8%A1%8C%7D)
c# public static bool IsSelectNode(string xmlPath,string node){XmlDocument xmlDoc = new XmlDocument();xmlDoc.Load(xmlPath);XmlNode result = xmlDoc.SelectSingleNode(@"//" + node);return result = null;//就这行}
c#
public static bool IsSelectNode(string xmlPath,string node)
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(xmlPath);
XmlNode result = xmlDoc.SelectSingleNode(@"//" + node);
return result = null;//就这行
}
c# public static bool IsSelectNode(string xmlPath,string node){XmlDocument xmlDoc = new XmlDocument();xmlDoc.Load(xmlPath);XmlNode result = xmlDoc.SelectSingleNode(@"//" + node);return result = null;//就这行}
return result != null;
这行是反会是否获取到你的XML文档的判断!
如果没获取到文档那么result肯定为NULL,则result != null返回的就是false
如果获取到了那么result != null返回的就是true