1
I have the code below, but I’m not able to list the node name and its value. I can search and show the main node type [ide] but the sub-node that would be [Cuf] + value that I can’t.
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 the 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]
Wouldn’t have to follow the same logic of the search for
ide
putting two bars before? That way:Doc.selectNodes('//ide').item[i].selectSingleNode('//cUF').text
– Roberto de Campos
I already did. But it does not go to the next modules, I needed to loop and pass Knot to Knot, thing that is not doing. And for some reason I can’t catch the name of the knot.
– araujolops
So I don’t understand your question, you want to sweep all knots from the knot
ide
?– Roberto de Campos
If possible, add in question the desired output.
– Roberto de Campos
That’s right, open the XML put in a loop and go through the nodes. I’m playing the test level values for a memo, but I’m going to play these values for a table... Example I need to go through the xml starting the <Cfe> node, to get the subnodes and their values.
– araujolops