Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   XML (https://www.delphipraxis.net/46-xml/)
-   -   Delphi bdsproj-file lesen? (https://www.delphipraxis.net/93003-bdsproj-file-lesen.html)

ralfiii 30. Mai 2007 08:26


bdsproj-file lesen?
 
Hallo!

Ich muss ein paar bdsproj-files manipulieren und lese sie dazu mit der
TXMLDocument-Komponente ein.

Nur: Wie komm ich auf die Knoten, die sind ... irgendwie anders als
ich das sonst so von XML-files kenne.

Altes (mir bekanntes) XML-Format:

XML-Code:
<BorlandProject>
  <PersonalityInfo>
    <Option>
      <Personality>Delphi.Personality</Personality>
      <ProjectType>VCLApplication</ProjectType>
      <Version>1.0</Version>
  </PersonalityInfo>
"Neues" "Borland" Format:
(Man beachte, die Blätter sind anders - statt <Personality> steht da <Option Name="Personality">.

XML-Code:
<BorlandProject>
  <PersonalityInfo>
    <Option>
      <Option Name="Personality">Delphi.Personality</Option>
      <Option Name="ProjectType">VCLApplication</Option>
      <Option Name="Version">1.0</Option>
  </PersonalityInfo>
Wie kann ich jetzt z.B. den Wert von PersonalityType auslesen?

Folgendes schlägt fehl:

Delphi-Quellcode:
     with TXMLDocument.Create(self) do
     begin
          LoadFromFile(FileNameEdit1.Text);
          with DocumentElement.ChildNodes['PersonalityInfo'].ChildNodes['Option'] do
          begin
               Memo1.Lines.Add( ChildNodes['Option Name="Personality"'].Text); // illegal!
Wie jetzt?

Danke,
Ralf

Luckie 30. Mai 2007 08:43

Re: bdsproj-file lesen?
 
Das
XML-Code:
Name="Personality"
sind doch ganz normale Attribute, wie sie in jeder XML-Datei vorkommen können. Dami hat Borland wohl die Knoten noch etwas differenziert.

ralfiii 30. Mai 2007 08:57

Re: bdsproj-file lesen?
 
Zitat:

Zitat von Luckie
Das
XML-Code:
Name="Personality"
sind doch ganz normale Attribute, wie sie in jeder XML-Datei vorkommen können. Dami hat Borland wohl die Knoten noch etwas differenziert.

Aha, OK, aber wie lese ich diese Attribute aus bzw. wie kann ich eines von den Attributen verändern?

Luckie 30. Mai 2007 08:58

Re: bdsproj-file lesen?
 
Benutz bitte die Forensuche, das hatten wir schon öfters.

ralfiii 30. Mai 2007 09:42

Re: bdsproj-file lesen?
 
Ah, OK, ich beginne das Ganze zu verstehen.

Zusammengefasst: Am Knoten "Option" hängen vier Subknoten die auch wieder "Option" heissen, und die jeweils ein Attribut "Name" haben. Der Inhalt von "Name" bestimmt was das für ein Knoten eigentlich ist.

Jetzt hab ich aber doch noch ein Problem:

Wie komm ich schnell auf meinen "Zielknoten"?
Also, von den 4 "Option"-Knoten möchte ich jenen haben, wo das Attribut "Name" gleich "Personality" ist.

Muss ich das mit einer Schleife ausprogrammieren oder gibt's da eine fertige Funktionalität?

Danke,
Ralf


Alle Zeitangaben in WEZ +1. Es ist jetzt 23:12 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz