Modifica

Condividi tramite


XStreamingElement Constructors

Definition

Initializes a new instance of the XStreamingElement class.

Overloads

XStreamingElement(XName)

Initializes a new instance of the XElement class from the specified XName.

XStreamingElement(XName, Object)

Initializes a new instance of the XStreamingElement class with the specified name and content.

XStreamingElement(XName, Object[])

Initializes a new instance of the XStreamingElement class with the specified name and content.

Remarks

Queries are not iterated until the XStreamingElement is serialized. This is in contrast to using queries for content for an XElement, where queries are iterated at the time of construction of the new XElement.

For details about the valid content that can be passed to this constructor, see Valid Content of XElement and XDocument Objects.

XStreamingElement(XName)

Source:
XStreamingElement.cs
Source:
XStreamingElement.cs
Source:
XStreamingElement.cs

Initializes a new instance of the XElement class from the specified XName.

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)

Parameters

name
XName

An XName that contains the name of the element.

Examples

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)

This example produces the following output:

<NewRoot>
  <DifferentChild>3</DifferentChild>
  <DifferentChild>4</DifferentChild>
  <DifferentChild>5</DifferentChild>
</NewRoot>

Remarks

This constructor creates a streaming element with no content and no attributes.

There is an implicit conversion from string to XName. Typical use of this constructor is to specify a string as the parameter instead of creating a new XName.

See also

Applies to

XStreamingElement(XName, Object)

Source:
XStreamingElement.cs
Source:
XStreamingElement.cs
Source:
XStreamingElement.cs

Initializes a new instance of the XStreamingElement class with the specified name and content.

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)

Parameters

name
XName

An XName that contains the element name.

content
Object

The contents of the element.

Examples

This example uses the following XML file, named Source.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>

Remarks

This constructor creates a streaming element with the specified content and attributes.

There is an implicit conversion from string to XName. Typical use of this constructor is to specify a string as the parameter instead of creating a new XName.

Queries are not iterated until the XStreamingElement is serialized. This is in contrast to using queries for content for an XElement, where queries are iterated at the time of construction of the new XElement.

For details about the valid content that can be passed to this constructor, see Valid Content of XElement and XDocument Objects.

See also

Applies to

XStreamingElement(XName, Object[])

Source:
XStreamingElement.cs
Source:
XStreamingElement.cs
Source:
XStreamingElement.cs

Initializes a new instance of the XStreamingElement class with the specified name and content.

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

Parameters

name
XName

An XName that contains the element name.

content
Object[]

The contents of the element.

Examples

This example uses the following XML file, named Source.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>

Remarks

This constructor creates a streaming element with the specified content and attributes.

There is an implicit conversion from string to XName. Typical use of this constructor is to specify a string as the parameter instead of creating a new XName.

Queries are not iterated until the XStreamingElement is serialized. This is in contrast to using queries for content for an XElement, where queries are iterated at the time of construction of the new XElement.

For details about the valid content that can be passed to this function, see Valid Content of XElement and XDocument Objects.

See also

Applies to