Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   XML (https://www.delphipraxis.net/46-xml/)
-   -   Delphi Attributes? Was mache ich falsch? (https://www.delphipraxis.net/94885-attributes-mache-ich-falsch.html)

la.reunion 27. Jun 2007 17:48


Attributes? Was mache ich falsch?
 
Holla,

Ich habe folgenden Code um eine XML-Datei mithilfe des TXMLDocuments zu erstellen:

Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);

var
  xml : TXMLDocument;
  node : IXMLNode;
begin
  xml:=TXMLDocument.Create(Self);
  xml.Active:=true;
  node:=xml.AddChild('artworkinfo');
  node:=node.AddChild('albuminfo');
  node := node.AddChild('artlocation');

  node.Attributes['artlocation'] := 'Image.jpg';

  node:=node.ChildNodes.First;
        xml.SaveToFile('C:\test.xml');
Das Problem an der Sache ist nur das die Struktur wie ich sie nachher haben will so nicht stimmt. Nachher sollte es nämlich so aussehen:

Delphi-Quellcode:

- <artworkinfo>
- <albuminfo>
  <artLocation>Stella_and_Henry_Hot_Dogs_2.JPG</artLocation>
  <trackName>Hot Diggity Dog</trackName>
  <artist>Kirupa Chinnathambi</artist>
  <albumName>Time For Lunch</albumName>
  <httptype>artwork/</httptype>
  </albuminfo>
- <albuminfo>
  <artLocation>tha_album.gif</artLocation>
  <trackName>Yo Yo Yo</trackName>
  <artist>Some Black Rapper</artist>
  <albumName>Tha Album</albumName>
  <httptype>artwork/</httptype>
  </albuminfo>

wie schaffe ich es denn das es von der struktur her so ist?


Danke Lg

marabu 27. Jun 2007 18:00

Re: Attributes? Was mache ich falsch?
 
Hallo,

du willst kein Attribut setzen, sondern den Content:

Delphi-Quellcode:
node.text := 'content';
Grüße vom marabu

la.reunion 27. Jun 2007 18:14

Re: Attributes? Was mache ich falsch?
 
Warum in die Ferne schweifen, das schöne liegt doch so nah.

:D



Vielen Dank!


Alle Zeitangaben in WEZ +1. Es ist jetzt 19:23 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