How can I define the following XML as a string constant in my c# program.
<?xml version="1.0" encoding="utf-8"?>
<smil xmlns="http://www.w3.org/2001/SMIL20/Language">
<head>
<meta base="rtmp://dos.com/vevood" />
</head>
<body>
</body>
</smil>
Right now I save the above as a test file(file.txt) then use the following to load it into an xdocument:
XDocument.Load(@"G:\file.txt");
I would like to save the xml as a string then do something like:
XDocument.Load(string);
The problem is there are special characters in the xml.
What’s the easiest way to achieve my objective?
You should use
XDocument.Parse(string)to initialize it from string constant. Also use double quotes to escape"characters: