更新时间:2023-11-26 08:05:16
是的,还有另一种方法,通过使用 XDocument类 [ ^ ]。
Yes, there is another way, via using XDocument class[^].
string sloc = "http://192.168.6.22/Conditions.aspx";
XDocument xdoc = XDocument.Load("fullfilename.xml");
XNamespace xnsp = "http://www.sitemaps.org/schemas/sitemap/0.9";
//return loc node - if exists
var qry = xdoc.Descendants(xnsp + "loc")
.Where(a=>(string)a==sloc);
//or return boolean value (true/false)
//bool result = xdoc.Descendants(xnsp + "loc")
// .Any(a=>(string)a==sloc);
如果你想使用XPath类获得结果,请参考:使用XPath导航选择节点 [ ^ ]
试试!
If you want to get result using XPath class, please refer this: Select Nodes Using XPath Navigation[^]
Try!