I have the following XPATH line:
//det[@nItem="1"]/prod/cProd
That successfully selects the desired node using XPath Visualizer, where it identifies automatically the namespace, and you define in which namespace you want to select.
When I specify the namespace in C# with the following XPATH code:
"http://www.portalfiscal.inf.br/nfe//det[@nItem=\"1\"]/prod/cProd"
it gives me an XPathException:
An unhandled exception of type 'System.Xml.XPath.XPathException' occurred in System.Xml.dll Additional information: 'http://www.portalfiscal.inf.br/nfe//det[@nItem="1"]/prod/cProd' has an invalid qualified name.
(as you can see, it's not any escape character or anything, since it gives me what i've tried to reach in the exception)
How do I properly select this node providing that I know the namespace with XPath ?
--[EDIT]-- The complete line where I try to read the node:
doc.XPathSelectElement("http://www.portalfiscal.inf.br/nfe//det[@nItem=\"1\"]/prod/cProd").Value;
And the XML with unnecessary things cut out:
<?xml version="1.0" encoding="utf-8"?>
<enviNFe xmlns="http://www.portalfiscal.inf.br/nfe" versao="1.10">
<idLote>1</idLote>
<NFe>
<infNFe versao="1.10" Id="NFe31100118583682000178550010000077778397333128">
<det nItem="1">
<prod>
<cProd>111</cProd>
</prod>
</det>
</infNFe>
</NFe>
</enviNFe>
(The unnecessary things cut out should not be a problem, since XPath Visualizer brought me the node with no problems at all)