Export (0) Print
Expand All

XDocument.Parse Method

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.

  Name Description
Public method Static member Supported by Silverlight for Windows Phone Supported by Xbox 360 Parse(String) Creates a new XDocument from a string.
Public method Static member Supported by Silverlight for Windows Phone Supported by Xbox 360 Parse(String, LoadOptions) Creates a new XDocument from a string, optionally preserving white space, setting the base URI, and retaining line information.
Top

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.


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


Community Additions

ADD
Show:
© 2015 Microsoft