XElement 类

定义

表示一个 XML 元素。Represents an XML element. 有关用法信息和示例,请参阅本页的 XElement 类概述和“备注”部分。See XElement Class Overview and the Remarks section on this page for usage information and examples.

public ref class XElement : System::Xml::Linq::XContainer, System::Xml::Serialization::IXmlSerializable
public class XElement : System.Xml.Linq.XContainer, System.Xml.Serialization.IXmlSerializable
type XElement = class
    inherit XContainer
    interface IXmlSerializable
Public Class XElement
Inherits XContainer
Implements IXmlSerializable
继承
实现

示例

下面的示例创建一个 XML 树。The following example creates an XML tree. 新元素的内容来自 LINQ 查询。The content of the new element comes from a LINQ query.

XElement xmlTree1 = new XElement("Root",  
    new XElement("Child1", 1),  
    new XElement("Child2", 2),  
    new XElement("Child3", 3),  
    new XElement("Child4", 4),  
    new XElement("Child5", 5),  
    new XElement("Child6", 6)  
);  
  
XElement xmlTree2 = new XElement("Root",  
    from el in xmlTree1.Elements()  
    where((int)el >= 3 && (int)el <= 5)  
    select el  
);  
Console.WriteLine(xmlTree2);  
Dim xmlTree1 As XElement = _  
        <Root>  
            <Child1>1</Child1>  
            <Child2>2</Child2>  
            <Child3>3</Child3>  
            <Child4>4</Child4>  
            <Child5>5</Child5>  
            <Child6>6</Child6>  
        </Root>  
  
Dim xmlTree2 As XElement = _   
    <Root>  
        <%= From el In xmlTree1.Elements() _  
            Where el.Value >= 3 And el.Value <= 5 _  
            Select el %>  
    </Root>  
  
Console.WriteLine(xmlTree2)  

该示例产生下面的输出:This example produces the following output:

<Root>  
  <Child3>3</Child3>  
  <Child4>4</Child4>  
  <Child5>5</Child5>  
</Root>  

下面是同一个示例,但在这种情况下,XML 位于命名空间中。The following is the same example, but in this case the XML is in a namespace. 有关详细信息,请参阅使用XML 命名空间For more information, see Working with XML Namespaces.

XNamespace aw = "http://www.adventure-works.com";  
XElement xmlTree1 = new XElement(aw + "Root",  
    new XElement(aw + "Child1", 1),  
    new XElement(aw + "Child2", 2),  
    new XElement(aw + "Child3", 3),  
    new XElement(aw + "Child4", 4),  
    new XElement(aw + "Child5", 5),  
    new XElement(aw + "Child6", 6)  
);  
  
XElement xmlTree2 = new XElement(aw + "Root",  
    from el in xmlTree1.Elements()  
    where((int)el >= 3 && (int)el <= 5)  
    select el  
);  
Console.WriteLine(xmlTree2);  
Imports <xmlns="http://www.adventure-works.com">  
  
Module Module1  
    Sub Main()  
        Dim xmlTree1 As XElement = _  
            <Root>  
                <Child1>1</Child1>  
                <Child2>2</Child2>  
                <Child3>3</Child3>  
                <Child4>4</Child4>  
                <Child5>5</Child5>  
                <Child6>6</Child6>  
            </Root>  
  
        Dim xmlTree2 As XElement = _   
            <Root>  
                <%= From el In xmlTree1.Elements() _  
                    Where el.Value >= 3 And el.Value <= 5 _  
                    Select el %>  
            </Root>  
  
        Console.WriteLine(xmlTree2)  
    End SUb  
End Module  

该示例产生下面的输出:This example produces the following output:

<Root xmlns="http://www.adventure-works.com">  
  <Child3>3</Child3>  
  <Child4>4</Child4>  
  <Child5>5</Child5>  
</Root>  

注解

此类表示 XML 元素,这是基本的 XML 构造。This class represents an XML element, the fundamental XML construct. 有关其他用法信息,请参阅System.xml.linq.xelement> 类概述See XElement Class Overview for other usage information.

元素有一个 XName,还可以选择包含一个或多个属性,还可以选择包含内容(有关详细信息,请参阅 Nodes)。An element has an XName, optionally one or more attributes, and can optionally contain content (for more information, see Nodes).

@No__t-0 可以包含以下类型的内容:An XElement can contain the following types of content:

有关 XElement 的有效内容的详细信息,请参阅system.xml.linq.xelement> 和 XDocument 对象的有效内容For details about the valid content of an XElement, see Valid Content of XElement and XDocument Objects.

@no__t 从 XNode 派生的 XContainer 派生。XElement derives from XContainer, which derives from XNode.

某些 XElement 方法可从 XAML 使用。Some XElement methods can be used from XAML. 有关详细信息,请参阅 LINQ to XML 动态属性For more information, see LINQ to XML Dynamic Properties.

构造函数

XElement(XElement)

从另一个 XElement 对象初始化 XElement 类的新实例。Initializes a new instance of the XElement class from another XElement object.

XElement(XName)

用指定的名称初始化 XElement 类的新实例。Initializes a new instance of the XElement class with the specified name.

XElement(XName, Object)

用指定的名称和内容初始化 XElement 类的新实例。Initializes a new instance of the XElement class with the specified name and content.

XElement(XName, Object[])

用指定的名称和内容初始化 XElement 类的新实例。Initializes a new instance of the XElement class with the specified name and content.

XElement(XStreamingElement)

XElement 对象初始化 XStreamingElement 类的新实例。Initializes a new instance of the XElement class from an XStreamingElement object.

属性

BaseUri

获取此 XObject 的基 URI。Gets the base URI for this XObject.

(继承自 XObject)
Document

获取此 XDocumentXObjectGets the XDocument for this XObject.

(继承自 XObject)
EmptySequence

获取空的元素集合。Gets an empty collection of elements.

FirstAttribute

获取此元素的第一个属性。Gets the first attribute of this element.

FirstNode

获取此节点的第一个子节点。Gets the first child node of this node.

(继承自 XContainer)
HasAttributes

获取一个值,该值指示此元素是否至少具有一个属性。Gets a value indicating whether this element has at least one attribute.

HasElements

获取一个值,该值指示此元素是否至少具有一个子元素。Gets a value indicating whether this element has at least one child element.

IsEmpty

获取一个值,该值指示此元素是否不包含内容。Gets a value indicating whether this element contains no content.

LastAttribute

获取此元素的最后一个属性。Gets the last attribute of this element.

LastNode

获取此节点的最后一个子节点。Gets the last child node of this node.

(继承自 XContainer)
Name

获取或设置此元素的名称。Gets or sets the name of this element.

NextNode

获取此节点的下一个同级节点。Gets the next sibling node of this node.

(继承自 XNode)
NodeType

获取此节点的节点类型。Gets the node type for this node.

Parent

获取此 XObject 的父级 XElementGets the parent XElement of this XObject.

(继承自 XObject)
PreviousNode

获取此节点的上一个同级节点。Gets the previous sibling node of this node.

(继承自 XNode)
Value

获取或设置此元素的串连文本内容。Gets or sets the concatenated text contents of this element.

方法

Add(Object)

将指定的内容添加为此 XContainer 的子级。Adds the specified content as children of this XContainer.

(继承自 XContainer)
Add(Object[])

将指定的内容添加为此 XContainer 的子级。Adds the specified content as children of this XContainer.

(继承自 XContainer)
AddAfterSelf(Object)

紧跟在此节点之后添加指定的内容。Adds the specified content immediately after this node.

(继承自 XNode)
AddAfterSelf(Object[])

紧跟在此节点之后添加指定的内容。Adds the specified content immediately after this node.

(继承自 XNode)
AddAnnotation(Object)

将对象添加到此 XObject 的批注列表。Adds an object to the annotation list of this XObject.

(继承自 XObject)
AddBeforeSelf(Object)

紧邻此节点之前添加指定的内容。Adds the specified content immediately before this node.

(继承自 XNode)
AddBeforeSelf(Object[])

紧邻此节点之前添加指定的内容。Adds the specified content immediately before this node.

(继承自 XNode)
AddFirst(Object)

将指定内容作为此文档或元素的第一个子级添加。Adds the specified content as the first children of this document or element.

(继承自 XContainer)
AddFirst(Object[])

将指定内容作为此文档或元素的第一个子级添加。Adds the specified content as the first children of this document or element.

(继承自 XContainer)
Ancestors()

返回此节点的上级元素的集合。Returns a collection of the ancestor elements of this node.

(继承自 XNode)
Ancestors(XName)

返回此节点的经过筛选的上级元素的集合。Returns a filtered collection of the ancestor elements of this node. 集合中仅包括具有匹配 XName 的元素。Only elements that have a matching XName are included in the collection.

(继承自 XNode)
AncestorsAndSelf()

返回元素集合,其中包含此元素及其上级。Returns a collection of elements that contain this element, and the ancestors of this element.

AncestorsAndSelf(XName)

返回经过筛选的元素集合,其中包含此元素及其上级。Returns a filtered collection of elements that contain this element, and the ancestors of this element. 集合中仅包括具有匹配 XName 的元素。Only elements that have a matching XName are included in the collection.

Annotation(Type)

从此 XObject 获取指定类型的第一个批注对象。Gets the first annotation object of the specified type from this XObject.

(继承自 XObject)
Annotation<T>()

从此 XObject 获取指定类型的第一个批注对象。Gets the first annotation object of the specified type from this XObject.

(继承自 XObject)
Annotations(Type)

获取此 XObject 的指定类型的批注集合。Gets a collection of annotations of the specified type for this XObject.

(继承自 XObject)
Annotations<T>()

获取此 XObject 的指定类型的批注集合。Gets a collection of annotations of the specified type for this XObject.

(继承自 XObject)
Attribute(XName)

返回具有指定 XAttribute 的此 XElementXNameReturns the XAttribute of this XElement that has the specified XName.

Attributes()

返回此元素的属性集合。Returns a collection of attributes of this element.

Attributes(XName)

返回经过筛选的此元素的属性集合。Returns a filtered collection of attributes of this element. 集合中仅包括具有匹配 XName 的元素。Only elements that have a matching XName are included in the collection.

CreateReader()

创建此节点的 XmlReaderCreates an XmlReader for this node.

(继承自 XNode)
CreateReader(ReaderOptions)

使用 readerOptions 参数指定的选项创建 XmlReaderCreates an XmlReader with the options specified by the readerOptions parameter.

(继承自 XNode)
CreateWriter()

创建可用于将节点添加至 XContainerXmlWriterCreates an XmlWriter that can be used to add nodes to the XContainer.

(继承自 XContainer)
DescendantNodes()

按文档顺序返回此文档或元素的子代节点集合。Returns a collection of the descendant nodes for this document or element, in document order.

(继承自 XContainer)
DescendantNodesAndSelf()

返回节点的集合,而这些节点包含此元素以及此元素的所有子代节点,并将它们按文档顺序排列。Returns a collection of nodes that contain this element, and all descendant nodes of this element, in document order.

Descendants()

按文档顺序返回此文档或元素的子代元素集合。Returns a collection of the descendant elements for this document or element, in document order.

(继承自 XContainer)
Descendants(XName)

按文档顺序返回此文档或元素的已筛选的子代元素集合。Returns a filtered collection of the descendant elements for this document or element, in document order. 集合中仅包括具有匹配 XName 的元素。Only elements that have a matching XName are included in the collection.

(继承自 XContainer)
DescendantsAndSelf()

返回元素的集合,而这些元素包含此元素以及此元素的所有子代元素,并按文档顺序排列它们。Returns a collection of elements that contain this element, and all descendant elements of this element, in document order.

DescendantsAndSelf(XName)

返回经过筛选的元素集合,这些元素包含此元素以及此元素的所有子代元素,并按文档顺序排列它们。Returns a filtered collection of elements that contain this element, and all descendant elements of this element, in document order. 集合中仅包括具有匹配 XName 的元素。Only elements that have a matching XName are included in the collection.

Element(XName)

获取具有指定的 XName 的第一个(按文档顺序)子元素。Gets the first (in document order) child element with the specified XName.

(继承自 XContainer)
Elements()

按文档顺序返回此元素或文档的子元素集合。Returns a collection of the child elements of this element or document, in document order.

(继承自 XContainer)
Elements(XName)

按文档顺序返回此元素或文档的已筛选的子元素集合。Returns a filtered collection of the child elements of this element or document, in document order. 集合中仅包括具有匹配 XName 的元素。Only elements that have a matching XName are included in the collection.

(继承自 XContainer)
ElementsAfterSelf()

按文档顺序返回此节点后的同级元素集合。Returns a collection of the sibling elements after this node, in document order.

(继承自 XNode)
ElementsAfterSelf(XName)

按文档顺序返回此节点后经过筛选的同级元素的集合。Returns a filtered collection of the sibling elements after this node, in document order. 集合中仅包括具有匹配 XName 的元素。Only elements that have a matching XName are included in the collection.

(继承自 XNode)
ElementsBeforeSelf()

按文档顺序返回此节点前的同级元素集合。Returns a collection of the sibling elements before this node, in document order.

(继承自 XNode)
ElementsBeforeSelf(XName)

按文档顺序返回此节点前经过筛选的同级元素的集合。Returns a filtered collection of the sibling elements before this node, in document order. 集合中仅包括具有匹配 XName 的元素。Only elements that have a matching XName are included in the collection.

(继承自 XNode)
Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetDefaultNamespace()

获取此 XNamespace 的默认 XElementGets the default XNamespace of this XElement.

GetHashCode()

用作默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetNamespaceOfPrefix(String)

获取此 XElement 的与特定前缀关联的命名空间。Gets the namespace associated with a particular prefix for this XElement.

GetPrefixOfNamespace(XNamespace)

获取与此 XElement 的命名空间关联的前缀。Gets the prefix associated with a namespace for this XElement.

GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
IsAfter(XNode)

确定当前节点是否按文档顺序显示在指定节点之后。Determines if the current node appears after a specified node in terms of document order.

(继承自 XNode)
IsBefore(XNode)

确定当前节点是否按文档顺序显示在指定节点之前。Determines if the current node appears before a specified node in terms of document order.

(继承自 XNode)
Load(Stream)

使用指定的流创建一个新的 XElement 实例。Creates a new XElement instance by using the specified stream.

Load(Stream, LoadOptions)

使用指定流创建新的 XElement 实例,也可以选择保留空白,设置基 URI 和保留行信息。Creates a new XElement instance by using the specified stream, optionally preserving white space, setting the base URI, and retaining line information.

Load(String)

从文件加载 XElementLoads an XElement from a file.

Load(String, LoadOptions)

从文件加载 XElement,还可以选择保留空白、设置基 URI 和保留行信息。Loads an XElement from a file, optionally preserving white space, setting the base URI, and retaining line information.

Load(TextReader)

XElement 加载 TextReaderLoads an XElement from a TextReader.

Load(TextReader, LoadOptions)

XElement 加载 TextReader,还可以选择保留空白和行信息。Loads an XElement from a TextReader, optionally preserving white space and retaining line information.

Load(XmlReader)

XElement 加载 XmlReaderLoads an XElement from an XmlReader.

Load(XmlReader, LoadOptions)

XElement 加载 XmlReader 时,可以选择保留空白、设置基 URI 和保留行信息。Loads an XElement from an XmlReader, optionally preserving white space, setting the base URI, and retaining line information.

LoadAsync(Stream, LoadOptions, CancellationToken)

以异步方式创建新的 XElement 并使用指定的流初始化其基础 XML 树,可以选择保留空格。Asynchronously creates a new XElement and initializes its underlying XML tree using the specified stream, optionally preserving white space.

LoadAsync(TextReader, LoadOptions, CancellationToken)

以异步方式创建新的 XElement 并使用指定的文本读取器初始化其基础 XML 树,可以选择保留空格。Asynchronously creates a new XElement and initializes its underlying XML tree using the specified text reader, optionally preserving white space.

LoadAsync(XmlReader, LoadOptions, CancellationToken)

以异步方式创建新的 XElement 并使用指定的 XML 文本读取器初始化其基础 XML 树,可以选择保留空格。Asynchronously creates a new XElement and initializes its underlying XML tree using the specified XML reader, optionally preserving white space.

MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
Nodes()

按文档顺序返回此元素或文档的子节点集合。Returns a collection of the child nodes of this element or document, in document order.

(继承自 XContainer)
NodesAfterSelf()

按文档顺序返回此节点后的同级节点的集合。Returns a collection of the sibling nodes after this node, in document order.

(继承自 XNode)
NodesBeforeSelf()

按文档顺序返回此节点前的同级节点的集合。Returns a collection of the sibling nodes before this node, in document order.

(继承自 XNode)
Parse(String)

从包含 XML 的字符串加载 XElementLoad an XElement from a string that contains XML.

Parse(String, LoadOptions)

从包含 XML 的字符串加载 XElement,还可以选择保留空白和行信息。Load an XElement from a string that contains XML, optionally preserving white space and retaining line information.

Remove()

从节点父级中删除此节点。Removes this node from its parent.

(继承自 XNode)
RemoveAll()

从此 XElement 中移除节点和属性。Removes nodes and attributes from this XElement.

RemoveAnnotations(Type)

从此 XObject 移除指定类型的批注。Removes the annotations of the specified type from this XObject.

(继承自 XObject)
RemoveAnnotations<T>()

从此 XObject 移除指定类型的批注。Removes the annotations of the specified type from this XObject.

(继承自 XObject)
RemoveAttributes()

移除此 XElement 的属性。Removes the attributes of this XElement.

RemoveNodes()

从此文档或元素中移除子节点。Removes the child nodes from this document or element.

(继承自 XContainer)
ReplaceAll(Object)

将此元素的子节点和属性替换为指定的内容。Replaces the child nodes and the attributes of this element with the specified content.

ReplaceAll(Object[])

将此元素的子节点和属性替换为指定的内容。Replaces the child nodes and the attributes of this element with the specified content.

ReplaceAttributes(Object)

将此元素的属性替换为指定的内容。Replaces the attributes of this element with the specified content.

ReplaceAttributes(Object[])

将此元素的属性替换为指定的内容。Replaces the attributes of this element with the specified content.

ReplaceNodes(Object)

使用指定内容替换此文档或元素的子节点。Replaces the children nodes of this document or element with the specified content.

(继承自 XContainer)
ReplaceNodes(Object[])

使用指定内容替换此文档或元素的子节点。Replaces the children nodes of this document or element with the specified content.

(继承自 XContainer)
ReplaceWith(Object)

使用指定的内容替换此节点。Replaces this node with the specified content.

(继承自 XNode)
ReplaceWith(Object[])

使用指定的内容替换此节点。Replaces this node with the specified content.

(继承自 XNode)
Save(Stream)

将此 XElement 输出到指定的 StreamOutputs this XElement to the specified Stream.

Save(Stream, SaveOptions)

将此 XElement 输出到指定的 Stream,(可选)并指定格式设置行为。Outputs this XElement to the specified Stream, optionally specifying formatting behavior.

Save(String)

将此元素序列化为文件。Serialize this element to a file.

Save(String, SaveOptions)

将此元素序列化为文件,并可以选择禁用格式设置。Serialize this element to a file, optionally disabling formatting.

Save(TextWriter)

将此元素序列化为 TextWriterSerialize this element to a TextWriter.

Save(TextWriter, SaveOptions)

将此元素序列化为 TextWriter,并可以选择禁用格式设置。Serialize this element to a TextWriter, optionally disabling formatting.

Save(XmlWriter)

将此元素序列化为 XmlWriterSerialize this element to an XmlWriter.

SaveAsync(Stream, SaveOptions, CancellationToken)

将此 XElement 异步输出到 StreamAsynchronously outputs this XElement to a Stream.

SaveAsync(TextWriter, SaveOptions, CancellationToken)

将此 XElement 异步输出到 TextWriterAsynchronously outputs this XElement to a TextWriter.

SaveAsync(XmlWriter, CancellationToken)

将此 XElement 异步输出到 XmlWriterAsynchronously outputs this XElement to an XmlWriter.

SetAttributeValue(XName, Object)

设置属性的值、添加属性或移除属性。Sets the value of an attribute, adds an attribute, or removes an attribute.

SetElementValue(XName, Object)

设置子元素的值、添加子元素或移除子元素。Sets the value of a child element, adds a child element, or removes a child element.

SetValue(Object)

设置此元素的值。Sets the value of this element.

ToString()

返回此节点的缩进 XML。Returns the indented XML for this node.

(继承自 XNode)
ToString(SaveOptions)

返回此节点的 XML,还可以选择禁用格式设置。Returns the XML for this node, optionally disabling formatting.

(继承自 XNode)
WriteTo(XmlWriter)

将此元素写入 XmlWriterWrite this element to an XmlWriter.

WriteToAsync(XmlWriter, CancellationToken)

将此 XElement 异步写入到指定的编写器。Asynchronously writes this XElement to the specified writer.

操作员

Explicit(XElement to Boolean)

将此 XElement 的值强制转换为 BooleanCast the value of this XElement to a Boolean.

Explicit(XElement to DateTime)

将此 XElement 的值强制转换为 DateTimeCast the value of this XElement to a DateTime.

Explicit(XElement to DateTimeOffset)

将此 XAttribute 的值强制转换为 DateTimeOffsetCast the value of this XAttribute to a DateTimeOffset.

Explicit(XElement to Decimal)

将此 XElement 的值强制转换为 DecimalCast the value of this XElement to a Decimal.

Explicit(XElement to Double)

将此 XElement 的值强制转换为 DoubleCast the value of this XElement to a Double.

Explicit(XElement to Guid)

将此 XElement 的值强制转换为 GuidCast the value of this XElement to a Guid.

Explicit(XElement to Int32)

将此 XElement 的值强制转换为 Int32Cast the value of this XElement to an Int32.

Explicit(XElement to Int64)

将此 XElement 的值强制转换为 Int64Cast the value of this XElement to an Int64.

Explicit(XElement to Nullable<Boolean>)

将此 XElement 的值强制转换为 BooleanNullable<T>Cast the value of this XElement to a Nullable<T> of Boolean.

Explicit(XElement to Nullable<DateTime>)

将此 XElement 的值强制转换为 DateTimeNullable<T>Cast the value of this XElement to a Nullable<T> of DateTime.

Explicit(XElement to Nullable<DateTimeOffset>)

将此 XElement 的值强制转换为 DateTimeOffsetNullable<T>Cast the value of this XElement to a Nullable<T> of DateTimeOffset.

Explicit(XElement to Nullable<Decimal>)

将此 XElement 的值强制转换为 DecimalNullable<T>Cast the value of this XElement to a Nullable<T> of Decimal.

Explicit(XElement to Nullable<Double>)

将此 XElement 的值强制转换为 DoubleNullable<T>Cast the value of this XElement to a Nullable<T> of Double.

Explicit(XElement to Nullable<Guid>)

将此 XElement 的值强制转换为 GuidNullable<T>Cast the value of this XElement to a Nullable<T> of Guid.

Explicit(XElement to Nullable<Int32>)

将此 XElement 的值强制转换为 Int32Nullable<T>Cast the value of this XElement to a Nullable<T> of Int32.

Explicit(XElement to Nullable<Int64>)

将此 XElement 的值强制转换为 Int64Nullable<T>Cast the value of this XElement to a Nullable<T> of Int64.

Explicit(XElement to Nullable<Single>)

将此 XElement 的值强制转换为 SingleNullable<T>Cast the value of this XElement to a Nullable<T> of Single.

Explicit(XElement to Nullable<TimeSpan>)

将此 XElement 的值强制转换为 TimeSpanNullable<T>Cast the value of this XElement to a Nullable<T> of TimeSpan.

Explicit(XElement to Nullable<UInt32>)

将此 XElement 的值强制转换为 UInt32Nullable<T>Cast the value of this XElement to a Nullable<T> of UInt32.

Explicit(XElement to Nullable<UInt64>)

将此 XElement 的值强制转换为 UInt64Nullable<T>Cast the value of this XElement to a Nullable<T> of UInt64.

Explicit(XElement to Single)

将此 XElement 的值强制转换为 SingleCast the value of this XElement to a Single.

Explicit(XElement to String)

将此 XElement 的值强制转换为 StringCast the value of this XElement to a String.

Explicit(XElement to TimeSpan)

将此 XElement 的值强制转换为 TimeSpanCast the value of this XElement to a TimeSpan.

Explicit(XElement to UInt32)

将此 XElement 的值强制转换为 UInt32Cast the value of this XElement to a UInt32.

Explicit(XElement to UInt64)

将此 XElement 的值强制转换为 UInt64Cast the value of this XElement to a UInt64.

事件

Changed

在此 XObject 或其任何子代发生了更改时引发。Raised when this XObject or any of its descendants have changed.

(继承自 XObject)
Changing

当此 XObject 或其任何子代要发生更改时引发。Raised when this XObject or any of its descendants are about to change.

(继承自 XObject)

显式界面实现

IXmlLineInfo.HasLineInfo()

获取一个值,该值指示此 XObject 是否具有行信息。Gets a value indicating whether or not this XObject has line information.

(继承自 XObject)
IXmlLineInfo.LineNumber

获取基础 XmlReader 为此 XObject 报告的行号。Gets the line number that the underlying XmlReader reported for this XObject.

(继承自 XObject)
IXmlLineInfo.LinePosition

获取基础 XmlReader 为此 XObject 报告的行位置。Gets the line position that the underlying XmlReader reported for this XObject.

(继承自 XObject)
IXmlSerializable.GetSchema()

获取说明此对象的 XML 表示形式的 XML 方案定义。Gets an XML schema definition that describes the XML representation of this object.

IXmlSerializable.ReadXml(XmlReader)

从对象的 XML 表示形式生成该对象。Generates an object from its XML representation.

IXmlSerializable.WriteXml(XmlWriter)

将对象转换为其 XML 表示形式。Converts an object into its XML representation.

扩展方法

GetSchemaInfo(XElement)

获取已验证元素的架构验证后信息集 (PSVI)。Gets the post-schema-validation infoset (PSVI) of a validated element.

Validate(XElement, XmlSchemaObject, XmlSchemaSet, ValidationEventHandler)

此方法验证 XElement 子树是否与指定的 XmlSchemaObjectXmlSchemaSet 相符。This method validates that an XElement sub-tree conforms to a specified XmlSchemaObject and an XmlSchemaSet.

Validate(XElement, XmlSchemaObject, XmlSchemaSet, ValidationEventHandler, Boolean)

验证 XElement 子树是否与指定的 XmlSchemaObjectXmlSchemaSet 相符,并且可以选择使用架构验证后信息集 (PSVI) 填充 XML 树。Validates that an XElement sub-tree conforms to a specified XmlSchemaObject and an XmlSchemaSet, optionally populating the XML tree with the post-schema-validation infoset (PSVI).

CreateNavigator(XNode)

XPathNavigator 创建一个 XNodeCreates an XPathNavigator for an XNode.

CreateNavigator(XNode, XmlNameTable)

XPathNavigator 创建一个 XNodeCreates an XPathNavigator for an XNode. XmlNameTable 可以使 XPath 表达式的处理变得更高效。The XmlNameTable enables more efficient XPath expression processing.

XPathEvaluate(XNode, String)

计算 XPath 表达式。Evaluates an XPath expression.

XPathEvaluate(XNode, String, IXmlNamespaceResolver)

计算 XPath 表达式,使用指定的 IXmlNamespaceResolver 解析命名空间前缀。Evaluates an XPath expression, resolving namespace prefixes using the specified IXmlNamespaceResolver.

XPathSelectElement(XNode, String)

使用 XPath 表达式选择 XElementSelects an XElement using a XPath expression.

XPathSelectElement(XNode, String, IXmlNamespaceResolver)

使用 XPath 表达式选择 XElement,并使用指定的 IXmlNamespaceResolver 解析命名空间前缀。Selects an XElement using a XPath expression, resolving namespace prefixes using the specified IXmlNamespaceResolver.

XPathSelectElements(XNode, String)

使用 XPath 表达式选择一个元素集合。Selects a collection of elements using an XPath expression.

XPathSelectElements(XNode, String, IXmlNamespaceResolver)

使用 XPath 表达式选择一个元素集合,并使用指定的 IXmlNamespaceResolver 解析命名空间前缀。Selects a collection of elements using an XPath expression, resolving namespace prefixes using the specified IXmlNamespaceResolver.

ToXPathNavigable(XNode)

返回一个访问器,该访问器可用于导航和编辑指定的 XNodeReturns an accessor that allows you to navigate and edit the specified XNode.

适用于

另请参阅