у меня вот такое содержание XML-файла:
- Код: Выделить всё
<?xml version="1.0" encoding="ISO-8859-1"?>
<KLM445>
- <Header>
<Sendercode>123456</Sendercode>
<Sendername>Моя фмрма</Sendername>
<Externe-Referenz>20201022</Externe-Referenz>
- <Kopfdaten>
<Belegart>Rechnung</Belegart>
<Kopfadressen>
...
</Kopfadressen>
- </Kopfdaten>
- </Header>
Я хочу найти содержание тэга <Externe-Referenz> и вот как я это делаю:
- Код: Выделить всё
procedure TForm1.Button1Click(Sender: TObject);
var
PassNode: TDOMNode;
Doc: TXMLDocument;
begin
try
// Read in xml file from disk
ReadXMLFile(Doc, 'test.XML');
// Retrieve the "password" node
PassNode := Doc.DocumentElement.FindNode('Externe-Referenz');
// Write out value of the selected node
ShowMessage(PassNode.NodeValue); // will be blank
// The text of the node is actually a separate child node
ShowMessage(PassNode.FirstChild.NodeValue); // correctly prints "abc"
// alternatively
ShowMessage(PassNode.TextContent);
finally
// finally, free the document
Doc.Free;
end;
end;
Но почему то на ShowMessage всегда Exception ошибка.
Что я делаю не так?
Спасибо за помощь!