Class XmlDocumentExtensions
XmlDocument 扩展方法
Inherited Members
Namespace: Lett.Extensions
Assembly: Lett.Extensions.dll
Syntax
public static class XmlDocumentExtensions
Methods
| Improve this Doc View SourceSelectNodesEnumerable(XmlDocument, String)
选择匹配 XPath 表达式的节点集合
匹配结果为空时,返回 null
Declaration
public static IEnumerable<XmlNode> SelectNodesEnumerable(this XmlDocument this, string xpath)
Parameters
Type | Name | Description |
---|---|---|
XmlDocument | this | |
String | xpath | xpath |
Returns
Type | Description |
---|---|
IEnumerable<XmlNode> |
Examples
var xmlDoc = new XmlDocument();
xmlDoc.Load("System.Xml.XmlDocument/test.xml");
var xpath = "/functional/dataSource/storeSource/columns/column";
var rs = xmlDoc.SelectNodesEnumerable(xpath);
// rs.ToList()[0]?.Attributes?.GetNamedItem("name").Value; == "FRowId"
// xmlDoc.SelectNodesEnumerable(null); // error throw ArgumentNullException
xmlDoc = null;
var rs = xmlDoc.SelectNodesEnumerable(xpath); // error error throw ArgumentNullException
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ArgumentNullException |
|