XStreamingElement 构造函数
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
初始化 XStreamingElement 类的新实例。
重载
| 名称 | 说明 |
|---|---|
| XStreamingElement(XName) | |
| XStreamingElement(XName, Object) |
使用指定的名称和内容初始化类的新实例 XStreamingElement 。 |
| XStreamingElement(XName, Object[]) |
使用指定的名称和内容初始化类的新实例 XStreamingElement 。 |
注解
在序列化查询之前 XStreamingElement ,不会迭代查询。 这与对内容 XElement使用查询进行对比,即在构造新 XElement查询时对查询进行迭代。
有关可传递给此构造函数的有效内容的详细信息,请参阅 XElement 和 XDocument 对象的有效内容。
XStreamingElement(XName)
- Source:
- XStreamingElement.cs
- Source:
- XStreamingElement.cs
- Source:
- XStreamingElement.cs
- Source:
- XStreamingElement.cs
- Source:
- XStreamingElement.cs
public:
XStreamingElement(System::Xml::Linq::XName ^ name);
public XStreamingElement(System.Xml.Linq.XName name);
new System.Xml.Linq.XStreamingElement : System.Xml.Linq.XName -> System.Xml.Linq.XStreamingElement
Public Sub New (name As XName)
参数
示例
XElement srcTree = new XElement("Root",
new XElement("Child", 1),
new XElement("Child", 2),
new XElement("Child", 3),
new XElement("Child", 4),
new XElement("Child", 5)
);
XStreamingElement dstTree = new XStreamingElement("NewRoot",
from el in srcTree.Elements()
where (int)el >= 3
select new XElement("DifferentChild", (int)el)
);
Console.WriteLine(dstTree);
Dim srcTree As XElement = _
<Root>
<Child>1</Child>
<Child>2</Child>
<Child>3</Child>
<Child>4</Child>
<Child>5</Child>
</Root>
Dim dstTree As XStreamingElement = New XStreamingElement("NewRoot", _
From el In srcTree.Elements _
Where el.Value >= 3 _
Select <DifferentChild><%= el.Value %></DifferentChild> _
)
Console.WriteLine(dstTree)
此示例生成以下输出:
<NewRoot>
<DifferentChild>3</DifferentChild>
<DifferentChild>4</DifferentChild>
<DifferentChild>5</DifferentChild>
</NewRoot>
注解
此构造函数创建一个无内容和无属性的流元素。
有从字符串到 XName. 的隐式转换。 此构造函数的典型用法是将字符串指定为参数,而不是创建新的 XName。
另请参阅
适用于
XStreamingElement(XName, Object)
- Source:
- XStreamingElement.cs
- Source:
- XStreamingElement.cs
- Source:
- XStreamingElement.cs
- Source:
- XStreamingElement.cs
- Source:
- XStreamingElement.cs
使用指定的名称和内容初始化类的新实例 XStreamingElement 。
public:
XStreamingElement(System::Xml::Linq::XName ^ name, System::Object ^ content);
public XStreamingElement(System.Xml.Linq.XName name, object content);
public XStreamingElement(System.Xml.Linq.XName name, object? content);
new System.Xml.Linq.XStreamingElement : System.Xml.Linq.XName * obj -> System.Xml.Linq.XStreamingElement
Public Sub New (name As XName, content As Object)
参数
- content
- Object
元素的内容。
示例
此示例使用以下名为 Source.xml的 XML 文件:
<?xml version="1.0" encoding="utf-8" ?>
<Root>
<Child Key="01">
<GrandChild>aaa</GrandChild>
</Child>
<Child Key="02">
<GrandChild>bbb</GrandChild>
</Child>
<Child Key="03">
<GrandChild>ccc</GrandChild>
</Child>
</Root>
注解
此构造函数创建具有指定内容和属性的流式处理元素。
有从字符串到 XName. 的隐式转换。 此构造函数的典型用法是将字符串指定为参数,而不是创建新的 XName。
在序列化查询之前 XStreamingElement ,不会迭代查询。 这与对内容 XElement使用查询进行对比,即在构造新 XElement查询时对查询进行迭代。
有关可传递给此构造函数的有效内容的详细信息,请参阅 XElement 和 XDocument 对象的有效内容。
另请参阅
适用于
XStreamingElement(XName, Object[])
- Source:
- XStreamingElement.cs
- Source:
- XStreamingElement.cs
- Source:
- XStreamingElement.cs
- Source:
- XStreamingElement.cs
- Source:
- XStreamingElement.cs
使用指定的名称和内容初始化类的新实例 XStreamingElement 。
public:
XStreamingElement(System::Xml::Linq::XName ^ name, ... cli::array <System::Object ^> ^ content);
public XStreamingElement(System.Xml.Linq.XName name, params object[] content);
public XStreamingElement(System.Xml.Linq.XName name, params object?[] content);
new System.Xml.Linq.XStreamingElement : System.Xml.Linq.XName * obj[] -> System.Xml.Linq.XStreamingElement
Public Sub New (name As XName, ParamArray content As Object())
参数
- content
- Object[]
元素的内容。
示例
此示例使用以下名为 Source.xml的 XML 文件:
<?xml version="1.0" encoding="utf-8" ?>
<Root>
<Child Key="01">
<GrandChild>aaa</GrandChild>
</Child>
<Child Key="02">
<GrandChild>bbb</GrandChild>
</Child>
<Child Key="03">
<GrandChild>ccc</GrandChild>
</Child>
</Root>
注解
此构造函数创建具有指定内容和属性的流式处理元素。
有从字符串到 XName. 的隐式转换。 此构造函数的典型用法是将字符串指定为参数,而不是创建新的 XName。
在序列化查询之前 XStreamingElement ,不会迭代查询。 这与对内容 XElement使用查询进行对比,即在构造新 XElement查询时对查询进行迭代。
有关可传递给此函数的有效内容的详细信息,请参阅 XElement 和 XDocument 对象的有效内容。