Getting an XML node using LINQ
- by MarceloRamires
Somehow, using linq I can't test it with this CUF field in the beginning:
<NFe>
<infNFe versao="1.0" Id="NFe0000000000">
<ide>
<cUF>35</cUF>
<!--...-->
</ide>
</NFe>
With the following code:
XDocument document = XDocument.Load(@"c:\nota.xml");
var query = from NFe in document.Descendants("NFe")
select new
{
cuf = NFe.Element("infNFe").Element("ide").Element("cUF").Value
};
The whole XML loads into document (checked) but NFe.cuf gives me nothing. I guess the parameters inside the nodes are messing it up..
How do I get this "cuf" with linq?
What if I wanted the Id parameter in infNFe ?