I tried using this code: [C#]
var textReader = new XmlTextReader(path);
if (textReader.NamespaceURI == "http://www.portalfiscal.inf.br/nfe")
{
//...
}
My XML:
<?xml version="1.0" encoding="utf-8"?>
<NFe xmlns="http://www.portalfiscal.inf.br/nfe">
<infNFe version="2.00" Id="NFe31130317194994450127550012302143751002144567">
<ide>
//continue...
But my code always returns "" ...
Is there a easy way to get XML namespace?
new XmlTextReader()has been deprecated since .NET 2.0. You should be usingXmlReader.Create()instead. Depending on what else you're doing with the XML, you'll find LINQ to XML much easier than playing with XmlReaders.