39

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

How can I convert this to an XElement Object?

Chris
  • 5,882
  • 2
  • 32
  • 57
realn
  • 1,732
  • 3
  • 12
  • 20

1 Answers1

94

Use XElement.Parse method like below

XElement xmlTree = XElement.Parse("<Root><Child>Hey</Child></Root>");
Console.WriteLine(xmlTree);
xanatos
  • 109,618
  • 12
  • 197
  • 280