Autor Beitrag
basner
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 39



BeitragVerfasst: Fr 19.06.09 17:03 
Hallo.


Kann mir jemand kurz sagen wie ich in einem XML Dokument einen bestimmten Knoten mit dem dazu gehörigen Attribut finden kann?

Hab es mit FindNode versucht funktioniert aber leider nicht. :(
basner Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 39



BeitragVerfasst: Sa 20.06.09 16:55 
Bitte brauch dringend Rat.

Ich habe eine Knotenlise in der die Knoten zugewiesen sind. Das Problem ist das der Knoten (BankAccounts) manchmal nicht in dem XML Dokument bzw Knotenliste nicht vorkommt oder an einer anderen Stelle.

Ich brauche unbedingt die Attribute des Knoten jedenfalls was in den drinne steht nur die Stelle des Knoten und der Attribute ist nicht immer gleich. So das es zu einem Fehler beim einlesen kommt.

Es wird in dem Beispiel sogar dann durch gegangen wenn der Knoten BankAccounts gar nicht im XML Dokument vorhanden ist.

Was mache ich falsch?
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
   if Knotenliste.Nodes[1].ChildNodes.Nodes[1].NodeName = 'BankAccounts' then
    begin
        Memo1.Lines.Add('************');
        if Knotenliste.Nodes[1].ChildNodes.Nodes[1].ChildNodes[0].HasAttribute('bankName'then begin
        Memo1.Lines.Add(Knotenliste.Nodes[1].ChildNodes.Nodes[1].ChildNodes[0].Attributes['bankName']);
        end;
        Memo1.Lines.Add(Knotenliste.Nodes[1].ChildNodes.Nodes[1].ChildNodes[0].Attributes['bankCode']);
        Memo1.Lines.Add(Knotenliste.Nodes[1].ChildNodes.Nodes[1].ChildNodes[0].Attributes['eban']);
        Memo1.Lines.Add(Knotenliste.Nodes[1].ChildNodes.Nodes[1].ChildNodes[0].Attributes['swift']);
        Memo1.Lines.Add(Knotenliste.Nodes[1].ChildNodes.Nodes[1].ChildNodes[0].Attributes['accountNo']);
        Memo1.Lines.Add(Knotenliste.Nodes[1].ChildNodes.Nodes[1].ChildNodes[0].Attributes['street']);
        Memo1.Lines.Add(Knotenliste.Nodes[1].ChildNodes.Nodes[1].ChildNodes[0].Attributes['zip']);
        Memo1.Lines.Add(Knotenliste.Nodes[1].ChildNodes.Nodes[1].ChildNodes[0].Attributes['city']);
        Memo1.Lines.Add(Knotenliste.Nodes[1].ChildNodes.Nodes[1].ChildNodes[0].Attributes['isoCountryCode']);
        Memo1.Lines.Add('************');

    end;


Moderiert von user profile iconNarses: Code- durch Delphi-Tags ersetzt