Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting the children of XElement to string [duplicate]

Possible Duplicate:
Best way to get InnerXml of an XElement?

I am using an XElement to hold a block of HTML serverside.

I would like to convert the children of that XElement into a string, sort of like an "InnerHtml" property does in javascript.

Can someone help me on this please? :)

like image 797
Michael Avatar asked Jun 19 '10 15:06

Michael


1 Answers

The other answers will work if the element only contains other elements. If you want to include text as well, you'll want to use Nodes() instead of Elements():

var result = string.Concat(element.Nodes());
like image 74
Quartermeister Avatar answered Oct 22 '22 10:10

Quartermeister