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>
</infNFe>
</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 ?
--[EDIT]--
I had forgotten to give the "silly url in the beginning", what happens is that it is the NAMESPACE, (the non-displaying of the namespace of the xml in Firefox contributed)
Now this works:
XNamespace ns = "http://www.portalfiscal.inf.br/nfe";
XElement root = XElement.Load(@"c:\nota.xml");
textBox1.Text = root.Element(ns + "infNFe").Element(ns + "ide").Element(ns + "cUF").Value;
Is there a way to set the namespace somewhere, and not needing to put it in every single field call ?