Ich kann nicht verstehen, was dein genaues Problem ist. Den richtigen Knoten finden? Das Attribut im gefundenen Knoten auslesen?
Ich weiß nicht wie dein Dokument normal aussieht, aber hier mal als kleines Beispiel:
Delphi-Quellcode:
program Project22;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils,
Xml.XmlIntf,
Xml.XmlDoc,
Winapi.ActiveX;
function determineBoardName(
const ofNode: IXmlNode):
String;
var
pcbDataNode: IXmlNode;
begin
Result := EmptyStr;
pcbDataNode := ofNode.ChildNodes.FindNode('
PCBData');
if Assigned(pcbDataNode)
and pcbDataNode.HasAttribute('
BoardName')
then
Result := pcbDataNode.Attributes['
BoardName'];
end;
procedure justXmlThings();
const
xmlContent:
String =
'
<?xml version="1.0" encoding="UTF-16"?>' + sLineBreak +
'
<rootNode>' + sLineBreak +
'
<PCBData ' + sLineBreak +
'
RecipeName="E1_Linie2\HM\HM Fest\HM Fest#1\HI_1384009-06" ' + sLineBreak +
'
GenerateTraceData="True" ' + sLineBreak +
'
TraceRequiresPCBBarcode="False" ' + sLineBreak +
'
SiplaceProOID="28342960" ' + sLineBreak +
'
BoardName="test\HI_1384009-06" ' + sLineBreak +
'
SetupName="E1_Linie2\HM\HM Fest\HM Fest#1" ' + sLineBreak +
'
LineName="E1_Linie2" ' + sLineBreak +
'
/>' + sLineBreak +
'
</rootNode>';
var
xmlDoc: IXMLDocument;
rootNode: IXMLNode;
begin
xmlDoc := LoadXMLData(xmlContent);
rootNode := xmlDoc.DocumentElement;
WriteLn( determineBoardName(rootNode) );
end;
begin
try
CoInitializeEx(
nil, COINIT_SPEED_OVER_MEMORY);
try
justXmlThings();
finally
CoUninitialize();
end;
except
on E:
Exception do
Writeln(E.ClassName, '
: ', E.
Message);
end;
readln;
end.