score:8

Accepted answer

call t.tostring() instead of value. that will return the xml as a string. you may want to use the overload taking saveoptions to disable formatting. i can't check right now, but i suspect it will include the element tag (and elements) so you would need to strip this off.

note that if your html isn't valid xml, you will end up with an invalid overall xml file.

is the format of the xml file completely out of your control? it would be nicer for any html inside to be xml-encoded.

edit: one way of avoiding getting the outer part might be to do something like this (in a separate method called from your query, of course):

stringbuilder builder = new stringbuilder();
foreach (xnode node in element.nodes())
{
    builder.append(node.tostring());
}

that way you'll get html elements with their descendants and interspersed text nodes. basically it's the equivalent of innerxml, i strongly suspect.

score:0

tiptext= t.value,

xelement.value returns only the text that is directly inside the element. text in nested elements - html or otherwise - will not be included, and of course any &-entity-references will appear in their decoded form.

if you want the content as a string with markup you could call xelement.tostring(), possibly with saveoptions.disableformatting. but note this includes the wrapping < tip> element - that is, in web browser dom terms, it's the outerhtml not the innerhtml. to get the innerhtml you would have to join together all the tostring()s of the child xelement.nodes.

score:0

just use:

string.concat(element.nodes()) 

to get the content with html tags.

score:1

just use string.concat(tip.nodes()) to get the content with html tags


Related Query

More Query from same tag