Linq2XML not getting content of a node that contains html tags
Posted
by Dante
on Stack Overflow
See other posts from Stack Overflow
or by Dante
Published on 2010-04-15T13:48:53Z
Indexed on
2010/04/15
17:33 UTC
Read the original article
Hit count: 541
Xml
|linq-to-xml
Hi,
I have an XML file that I'm trying to parse with Linq2XML. One of the nodes contains a bit of html, that I cannot retrieve.
The XML resembles to:
<?xml version="1.0" encoding="ISO-8859-1"?>
<root>
<image><img src="/Images/m1cznk4a6fh7.jpg" /></image>
<contentType>Banner</contentType>
</root>
The code is:
XDocument document = XDocument.Parse(content.XML);
XElement imageElement = document.Descendants("image").SingleOrDefault();
image = imageElement.Value; // Doesn't get the content, while if I specify .Descendants("contentType") it works
Any ideas?
Thank you in advance
© Stack Overflow or respective owner