XDocument.Parse Method
Microsoft Silverlight will reach end of support after October 2021. Learn more.
Include Protected Members
Include Inherited Members
Include Silverlight Members
Include Silverlight for Windows Phone Members
Include XNA Framework Members
Creates a new XDocument from a string, optionally preserving white space, setting the base URI, and retaining line information.
This member is overloaded. For complete information about this member, including syntax, usage, and examples, click a name in the overload list.
Overload List
Name | Description | |
---|---|---|
Parse(String) | Creates a new XDocument from a string. | |
Parse(String, LoadOptions) | Creates a new XDocument from a string, optionally preserving white space, setting the base URI, and retaining line information. |
Top
Remarks
This method parses a string and creates an XML tree.
Examples
The following example creates a string that contains XML. It then parses the string into an XDocument.
Dim output As New StringBuilder
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)
output.Append(doc)
output.Append(Environment.NewLine)
OutputTextBlock.Text = output.ToString()
StringBuilder output = new StringBuilder();
string str =
@"<?xml version=""1.0""?>
<!-- comment at the root level -->
<Root>
<Child>Content</Child>
</Root>";
XDocument doc = XDocument.Parse(str);
output.Append(doc + Environment.NewLine);
OutputTextBlock.Text = output.ToString();
See Also