komische XML auslesen
Hallo,
ich habe folgenden XML Aufbau:
Code:
Irgendwie sieht das ja nicht ganz so aus, wie man eine XML machen würde ....
<?xml version="1.0" encoding="iso-8859-1" ?>
<artlist> <art eid="1442163" fab="140.20.01"/> <art eid="1442164" fab="140.20.02"/> <art eid="2341594" fab="142.20.01"/> </artlist> Nun lese ich das ein und will die Infos auslesen:
Delphi-Quellcode:
hier fehlt mir der nächste Schritt, wie es mit TXMLDocument weiter geht :oops:
XMLDocument1.Active:=False;
XMLDocument1.XML.Text:=xml; XMLDocument1.Active:=True; LNodeElement := XMLDocument1.ChildNodes.FindNode('artlist'); if (LNodeElement <> nil) then begin xxxxx end; |
AW: komische XML auslesen
Eigentlich ist das schon XML. Schau dir mal Attribute an. Damit solltest du weiter kommen.
EDIT: Hier mal ein kleines Beispiel wie man darauf zugreifen kann:
Delphi-Quellcode:
EDIT 2:
if (XmlNode.HasAttribute('active')) then begin
Temp := XmlNode.Attributes['active']; Result.Active := StrToBool(Temp); end; Sorry übersehen. Am Besten nutzt du
Delphi-Quellcode:
und dann
IXMLDocument
Delphi-Quellcode:
Hierfür müsstest du noch die Units:
var
Doc: IXMLDocument; begin Doc := LoadXMLDocument(FFileName); end;
Delphi-Quellcode:
einbinden.
Xml.XMLIntf, Xml.XMLDoc
|
AW: komische XML auslesen
Dank für den Hilfe, ich habe es aber nun, wie es geht:
Delphi-Quellcode:
XMLDocument1.Active:=False;
XMLDocument1.XML.Text:=xml; XMLDocument1.Active:=True; LNodeElement := XMLDocument1.ChildNodes.FindNode('artlist'); if (LNodeElement <> nil) then begin LNode:=LNodeElement.ChildNodes.First; TGrid_ArtList.RowCount:=LNodeElement.ChildNodes.Count+1; zeile:=1; while LNode<>nil do begin s:= LNode.NodeName; if (LNode.HasAttribute('eid')) then begin LAttrValue := LNode.Attributes['eid']; TGrid_ArtList.Cells[1,zeile]:=LAttrValue; end; if (LNode.HasAttribute('fab')) then begin LAttrValue := LNode.Attributes['fab']; TGrid_ArtList.Cells[2,zeile]:=LAttrValue; end; if zeile<LNodeElement.ChildNodes.Count then begin LNode := LNodeElement.ChildNodes.Get(Zeile); end else LNode:=nil; inc(zeile); end; end; XMLDocument1.Active:=False; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 15:58 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz