How to assign a C # variable

Possible duplicate:
Use XML literals in C #?

I can do it in Visual Basic, how to do it in C #

Dim xmlTree As XElement = <Employees></Employees> 
+4
source share
2 answers
 XDocument document = XDocument.Parse("<Employees></Employees>") 
+1
source

Try:

 XDocument document = XDocument.Parse("<Employees></Employees>") 

or

 XElement root = new XElement("Employees") 

Another way is to use the XmlDocument class:

 XmlDocument document = new XmlDocument(); document.LoadXml("<Employees></Employees>"); 

but I recommend using XDocument . It is newer than XmlDocument , it has a cleaner API and supports Linq To Xml .

+9
source

All Articles