-->

How to convert from string to XElement object

2019-06-14 20:50发布

问题:

I have a string like this: "<Root><Child>Hey</Child></Root>"

How can I convert this to an XElement Object?

回答1:

Use XElement.Parse method like below

XElement xmlTree = XElement.Parse("<Root><Child>Hey</Child></Root>");
Console.WriteLine(xmlTree);


标签: c# xml xelement