const
ELEM_RAPORT_WERYF = '
abc:raport-weryf';
ELEM_PROBLEM = '
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: 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:kpz="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));
with e.selectSingleNode(
{'//' +} ELEM_PROBLEM)
as IXMLDOMElement
do // EDIT
begin
kat := VarToStr(e.getAttribute(ATTR_KAT));
beschr := VarToStr(e.getAttribute(ATTR_BESCHR));
end;
end;
end else ShowParseError(xmlDoc);
end;