如题:检查 xml 中是否存在某个节点
/// <summary>
///
/// </summary>
/// <param name="xmlStr">xml 内容</param>
/// <param name="siteName">待查找的节点名称</param>
/// <returns></returns>
public bool CheckExistsXml(string xmlStr, string siteName)
{
var xdocC = new XmlDocument();
try
{
xdocC.LoadXml(xmlStr);
return xdocC.GetElementsByTagName(siteName)?.Count > 0;
}
catch
{
return false;
}
}