XElement class
https://docs.microsoft.com/zh-cn/dotnet/api/system.xml.linq.xelement?view=netframework-4.8
Represents an XML element.
The following example creates an XML tree. The content of the new element comes from the LINQ query.
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>
annotation
This class represents XML elements, which are basic XML constructs.
The element has an XName (one or more attributes can be selected), and can optionally include content (see Nodes for details ).
XElement can contain the following types of content:
Examples:
Dim root As New XElement("Company", _
New XAttribute("Type", "Publisher"), _
New XElement("CompanyName", "Wrox"), _
New XElement("CompanyAddress", _
New XElement("Street", "111 River Street"), _
New XElement("city", "Hoboken"), _
New XElement("State", "NJ"), _
New XElement("Counttr", "USA"), _
New XElement("Zip", "07030-5774")))
Console.WriteLine(root.ToString)
Console.WriteLine("Prss ENTER to exit")
Console.Read()