1
I am with the following example XML file:
<?xml version="1.0" encoding="UTF-8"?>
<EnviarLoteRpsEnvio xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.abrasf.org.br/nfse">
<LoteRps Id="Lote4">
<NumeroLote>4</NumeroLote>
<Cnpj>07160720000111</Cnpj>
<QuantidadeRps>1</QuantidadeRps>
<ListaRps>
<Rps xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.abrasf.org.br/nfse">
<InfRps Id="Rps0716072000016300500787">
<Prestador>
<Cnpj>07160720000222</Cnpj>
</Prestador>
<Tomador>
<IdentificacaoTomador>
<CpfCnpj>
<Cnpj>07160720000333</Cnpj>
</CpfCnpj>
</IdentificacaoTomador>
</Tomador>
</InfRps>
</Rps>
</ListaRps>
</LoteRps>
My goal is to obtain the information of each Cnpj TAG separately to be able to identify them as RPS, Provider and Policy Holder Cnpj.
I already managed to get the first XML Cnpj with this code C#
private void btnLerTag_Click(object sender, EventArgs e)
{
//Busca o primeiro CNPJ do XML
XmlDocument doc = new XmlDocument();
string ArquivoXML = txtCaminhoXML.Text;
doc.Load(ArquivoXML);
XmlNode root = doc.DocumentElement;
XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable);
nsmgr.AddNamespace("n", "http://www.abrasf.org.br/nfse");
XmlNode node = root.SelectSingleNode("//n:Cnpj", nsmgr);
foreach (XmlNode oNo in node)
{
lstXML.Items.Add(node.InnerXml);
}
}
Could someone give me some suggestion to solve this problem?
You want to know which one
node
belongs to the particularCnpj
?– novic
Exactly that!
– Thiagopsw