const
ELEM_RAPORT_WERYF = '
abc:raport-weryf';
ELEM_PROBLEM = '
abc:problem';
ATTR_ID_PROD = '
id-prod';
ATTR_WERS = '
wers';
ATTR_KAT = '
kat';
ATTR_BESCHR = '
beschr';
procedure ShowParseError(xd: IXMLDOMDocument2);
begin
ShowMessage(xd.parseError.reason);
end;
procedure TDemoForm.ButtonClick(Sender: TObject);
var
xmlDoc: IXMLDOMDocument2;
nl: IXMLDOMNodeList;
e, eProblem: IXMLDOMElement;
id_prod, version, kat, beschr, path:
string;
i: Integer;
begin
xmlDoc := CoDOMDocument40.Create;
xmlDoc.setProperty('
NewParser', True);
xmlDoc.setProperty('
SelectionLanguage', '
XPath');
xmlDoc.setProperty('
SelectionNamespaces', '
xmlns:abc="www.bla.gov.pl/xml/zaehler/1"');
if xmlDoc.load(Path + DATABASE_FNAME + '
.xml')
then
begin
nl := xmlDoc.documentElement.selectNodes('
//' + ELEM_RAPORT_WERYF);
for i := 0
to Pred(nl.length)
do
begin
e := nl.item[i]
as IXMLDOMElement;
id_prod := VarToStr(e.getAttribute(ATTR_ID_PROD));
version := VarToStr(e.getAttribute(ATTR_WERS));
eProblem := e.selectSingleNode(ELEM_PROBLEM)
as IXMLDOMElement;
if Assigned(eProblem)
then
begin
kat := VarToStr(eProblem.getAttribute(ATTR_KAT));
beschr := VarToStr(eProblem.getAttribute(ATTR_BESCHR));
ShowMessage(kat + sLineBreak + beschr);
end;
end;
end else ShowParseError(xmlDoc);
end;