Moin Tom,
die Messages sind kein gültiges
XML, wenn die Tags nicht auch geschlossen werden.
Delphi-Quellcode:
procedure GetAttributeValues(
const sOpenTag:
string; list: TStrings);
var
i: Integer;
map: IXMLDOMNamedNodeMap;
begin
with CoDOMDocument.Create
do
begin
async := False;
if LoadXML(StringReplace(sOpenTag, '
>', '
/>', []))
then
begin
list.BeginUpdate;
try
list.Clear;
map := DocumentElement.attributes;
for i := 0
to Pred(map.length)
do
list.Values[map.item[i].nodeName] := VarToStr(map.item[i].nodeValue);
finally
list.EndUpdate;
end;
end else raise Exception.Create(ParseError.Reason);
end;
end;
const
MSG
= '
<MatchStats id="MS004" matchid="ATP2008WG MS004" seq="122" state="P" '
+ '
tim="2008-02-12T08:58:54Z" msg="" score="2/6 3/6 1/0" points="0-30" '
+ '
rnd=" " dbl="1" crt="5" nset="5" stype="1">'
;
procedure TDemoForm.ButtonClick(Sender: TObject);
begin
GetAttributeValues(MSG, ValueListEditor.Strings);
end;