Show / Hide Table of Contents

    Class XmlDocumentExtensions

    XmlDocument 扩展方法

    Inheritance
    Object
    XmlDocumentExtensions
    Inherited Members
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Object.ReferenceEquals(Object, Object)
    Object.ToString()
    Namespace: Lett.Extensions
    Assembly: Lett.Extensions.dll
    Syntax
    public static class XmlDocumentExtensions

    Methods

    | Improve this Doc View Source

    SelectNodesEnumerable(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

    this is null

    ArgumentNullException

    xpath is null

    • Improve this Doc
    • View Source
    Back to top Copyright (c) 2019 viacooky. All rights reserved.