XDocument.Parse Method

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Creates a new XDocument from a string, optionally preserving white space, setting the base URI, and retaining line information.

Namespace:   System.Xml.Linq
Assembly:  System.Xml.Linq (in System.Xml.Linq.dll)

NameDescription
System_CAPS_pubmethodSystem_CAPS_staticParse(String)

Creates a new XDocument from a string.

System_CAPS_pubmethodSystem_CAPS_staticParse(String, LoadOptions)

Creates a new XDocument from a string, optionally preserving white space, setting the base URI, and retaining line information.

This method parses a string and creates an XML tree.

The following example creates a string that contains XML. It then parses the string into an XDocument.


                Dim str As String = _
    "<?xml version= '1.0'?>" & _
    "<!-- comment at the root level -->" & _
    "<Root>" & _
    "  <Child>Content</Child>" & _
    "</Root>"

Dim doc As XDocument = XDocument.Parse(str)
Console.WriteLine(doc)

This example produces the following output:


                <!-- comment at the root level -->
<Root>
  <Child>Content</Child>
</Root>
Return to top
Show: