I have this simple xml :
<AllBands>
<Band>
<Name ID="1234" started="1962">Beatles<![CDATA[lalala]]></Name>
<Last>1</Last>
<Salary>2</Salary>
</Band>
<Band>
<Name ID="222" started="1968">Doors<![CDATA[lalala]]></Name>
<Last>1</Last>
<Salary>2</Salary>
</Band>
</AllBands>
I want to read the "bealtes
" value from the Name
element
by
using (var stream = new StringReader(result))
{
XDocument xmlFile = XDocument.Load(stream);
var query = from c in xmlFile.Descendants("Band") select c;
foreach (XElement band in query)
{
if (band.Element("Name").Value ==...) // this expression is beatleslalala
// and not beatles alone...
}
}
why is that? why does he includes the cdata? How can i get the "beatles" only?