I have the following code, but I am not able to list the node name and its value. I can search and show the main node [ide] but the sub-node that would be [cUF] + value this I can not.
procedure TForm1.Button3Click(Sender: TObject);
var
Doc: IXMLDOMDocument;
Element: IXMLDOMElement;
List: IXMLDOMNodeList;
attrib : IXMLDOMNode;
Path,ID,title,producer: string;
i: integer;
begin
Memo1.Lines.Clear;
Doc := CoDOMDocument.Create;
Doc.load(ArquivoXML);
// Element := Doc.documentElement;
// List := Element.getElementsByTagName('ide');
for i := 0 to Doc.selectNodes('//ide').length do
begin
Memo1.Lines.Add(Doc.selectNodes('//ide').item[i].baseName); // Nó onde está parado
Memo1.Lines.Add(Doc.selectNodes('//ide').item[i].Get_nodeName); // = basename
Memo1.Lines.Add(Doc.selectNodes('//ide').item[i].nodeName); // = basename
Memo1.Lines.Add(Doc.selectNodes('//ide').item[i].selectSingleNode('cUF').text); // Pego o Conteúdo do item do Nó
Memo1.Lines.Add(Doc.selectNodes('//ide').item[i].selectSingleNode('cNF').text); // Pego o Conteúdo do item do Nó
// Memo1.Lines.Add(IntToStr(GetNodeInt(attrib,'cNF')));
end;
end;
Excerpt from XML :
[CFe]
[infCFe versaoSB="000003" versaoDadosEnt="0.07" versao="0.07"
Id="CFeNumero_da_chave"]
[ide]
[cUF]35[/cUF]
[cNF]164796[/cNF]
[mod]59[/mod]
[nserieSAT]123456789[/nserieSAT]
[nCFe]000289[/nCFe]
[dEmi]20181029[/dEmi]
[hEmi]100256[/hEmi]
[cDV]3[/cDV]
[tpAmb]2[/tpAmb]
[CNPJ]11111111111111[/CNPJ]
[signAC]assinatura[/signAC]
[assinaturaQRCODE]QRCode[/assinaturaQRCODE]
[numeroCaixa]002[/numeroCaixa]
[/ide]
[/infCFe"
[/CFe]