You can create XML Literals and populate them with the contents from an external source such as a file, a string, or a stream by using several methods. These methods are shown in the following examples.
Your computer might show different names or locations for some of the Visual Studio user interface elements in the following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For more information, see Personalizing the IDE.
To load XML from a file
To populate an XML literal such as an XElement or XDocument object from a file, use the Load method. This method can take a file path, text stream, or XML stream as input.
The following code example shows the use of the Load(String) method to populate an XDocument object with XML from a text file.