Create a single XML element : XElement « XML LINQ « VB.Net






Create a single XML element

    


Class Car
  Public PetName As String
  Public ID As Integer
End Class

Module Program
  Sub Main()
    Dim inventory As XElement = _
    <Inventory>
      <Car ID="1">
        <Color>Green</Color>
        <Make>BMW</Make>
        <PetName>Stan</PetName>
      </Car>
    </Inventory>

    ' Call ToString() on our XElement.
    Console.WriteLine(inventory)

  End Sub


End Module

   
    
    
    
  








Related examples in the same category

1.Build an XElement from string
2.After elements
3.Before elements
4.Create an in-memory XML document
5.First name element has attributes
6.First name tag has child elements
7.FirstLast Or Default Example
8.First Last Example
9.FirstName tag's parent has child elements
10.Get first descendant
11.Using Xml Linq to output Html
12.Xml Literal with string variable
13.Xml literal with function return
14.Enumerate over the array to build an XElement
15.Create a query to convert the xml data into fields delimited by quotes and commas.
16.Convert comma separated value to Xml
17.Get child elements by name directly
18.Get value of each color using indexer
19.Is FirstName tag empty?
20.Is idperson tag empty?
21.Using Ling query to create Xml output
22.The Root property returns the top-level XElement
23.Set new value to Xml document
24.Selects an XElement using a XPath expression.
25.XElement Represents an XML element.
26.Selects an XElement using a XPath expression.
27.XElement Class represents an XML element.
28.Create XElement class.
29.Create XElement class from another XElement object.
30.Create XElement class with the specified name.
31.Create XElement class with the specified name and content.
32.XElement object content
33.XElement object array content
34.Create XElement class with the specified name and content.
35.Create XElement class from an XStreamingElement object.
36.XElement.AncestorsAndSelf Method returns a collection of elements that contain this element, and the ancestors of this element.
37.XElement.AncestorsAndSelf (XName) returns a filtered collection of elements
38.XElement.Attributes returns a collection of attributes of this element.
39.XElement.Attributes (XName) returns a filtered collection of attributes of this element
40.XElement.DescendantNodesAndSelf returns nodes that contain this element, and all descendant nodes
41.XElement.HasAttributes tells whether this element as at least one attribute.
42.XElement.HasElements tells whether this element has at least one child element.
43.XElement.IsEmpty tells whether this element contains no content.
44.XElement.LastAttribute gets the last attribute of this element.
45.XElement.Name Property gets or sets the name of this element.
46.XElement.NodeType Property gets the node type for this node.
47.XElement.SetValue sets the value of this element.
48.XElement.Value Property gets or sets the concatenated text contents of this element.
49.Imports xmlns and use it with XElement
50.XObject.Parent Property gets the parent XElement of this XObject.
51.Extensions.AncestorsAndSelf
52.Extensions.Descendants
53.Extensions.Descendants(T)
54.Extensions.Elements(T) returns a collection of the child elements
55.Extensions.Elements(T) returns a filtered collection of the child elements
56.Extensions.XPathEvaluate evaluates an XPath expression.
57.String content
58.Double content
59.DateTime content
60.String array content
61.Returns elements containing this element and all descendant elements
62.Returns a filtered collection of elements containing this element and all descendant elements of this element
63.Get Ancestors