XDocument.Parse Method (String)
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Creates a new XDocument from a string.
Assembly: System.Xml.Linq (in System.Xml.Linq.dll)
Parameters
- text
- Type: System.String
A string that contains XML.
Return Value
Type: System.Xml.Linq.XDocumentAn XDocument populated from the string that contains XML.
This method does not preserve white space. If you want to preserve white space in the XML tree, use the overload of Parse that takes LoadOptions as a parameter.
LINQ to XML's loading functionality is built upon XmlReader. Therefore, you might catch any exceptions that are thrown by the XmlReader.Create overload methods and the XmlReader methods that read and parse the document.
The following example creates a string that contains XML. It then parses the string into an XDocument.