IndexHunter - Fr 20.08.10 02:42
Titel: OmniXML - kann keine XML erstellen
Ich versuche ein XML Dokument zu erstellen. Es soll ein root haben und dann ein Kind 'childofroot'. Funktionert nur nicht.
Die a.xml ist immer 0 Bytes gross
Delphi-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14:
| procedure TForm1.Button4Click(Sender: TObject); var xml: TXMLDocument; root: IXMLElement; begin xml := TXMLDocument.Create; root := xml.CreateElement('root'); xml.DocumentElement := root;
xml.DocumentElement.AppendChild(xml.CreateElement('childOfRoot'));
xml.Save('C:\Users\Lukas\Desktop\a.xml', ofIndent); end; |
Warum funktionierts nicht?
---
Moderiert von
Narses: Beiträge zusammengefasst---
Das geht:
Delphi-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20:
| procedure TForm1.Button4Click(Sender: TObject); var xml: IXMLDocument; root: IXMLElement; inhalt1: IXMLElement; inhalt2: IXMLElement; begin xml := CreateXMLDoc; root := xml.CreateElement('root'); root.Text := 'This is the root directory'; xml.DocumentElement := root; inhalt1 := xml.CreateElement('inhalt'); inhalt1.Text := 'Das hier ist der Inhalt'; inhalt2 := xml.CreateElement('inhalt2'); inhalt2.Text := 'Das hier ist Inhalt 2. Ein schöner Inhalt.'; root.AppendChild(inhalt1); root.AppendChild(inhalt2);
xml.Save('C:\Users\Lukas\Desktop\output.xml', ofIndent); end; |