4
我可以在Visual Basic中做到这一点,我怎么能做到这一点在C#
Dim xmlTree As XElement = <Employees></Employees>
我可以在Visual Basic中做到这一点,我怎么能做到这一点在C#
Dim xmlTree As XElement = <Employees></Employees>
XDocument document = XDocument.Parse("<Employees></Employees>")
Try:
XDocument document = XDocument.Parse("<Employees></Employees>")
或
XElement root = new XElement("Employees")
另一种方法是使用XmlDocument
类:
XmlDocument document = new XmlDocument();
document.LoadXml("<Employees></Employees>");
,但我建议使用XDocument。它比XmlDocument
更新,它有更清洁的API和支持Linq To Xml。
C#(至少4个及以下)不*支持XML文字。 '新的XElement(“Employees”)'会在这里工作,但XElement也可以解析更大的[逐字]文本。 – 2013-01-14 04:46:56
http://stackoverflow.com/questions/8768762/use-xml-literals-in-c,http://www.codeproject.com/Tips/84852/TRICK-Xml-Literals-for-C –