I have a XML source with nodes like this (Somewhat anonymized):
<XXX>
<Code A="oa ">01</Code>
<Name A="oa ">Card</Name>
<F1 A="oa ">x</F1>
<F2 A="oa ">y</F2>
<F3 A="oa ">z</F3>
</XXX>
I load the XML-document into a XElement and query it with linq
var query = from creditcard in xml.Descendants("XXX")
where creditcard.Element("Code").Value == "1"
select new
{
Id = Convert.ToInt32(creditcard.Element("Code").Value),
Description = creditcard.Element("Name").Value,
xx = creditcard.Element("F1").Value,
yy = creditcard.Element("F2").Value,
zz = creditcard.Element("F3").Value
};
This will result in a empty set when I dump the query in LinqPad. However if I change the where clause to:
where Convert.ToInt32(creditcard.Element("Code").Value) == 1
Then it will correctly find the item in question. Any ideas why it works this way or what I have missed?
EDIT: Sorry, I missed to change a "Kod" to Code as I changed it for posting. Fixed now.