K
Ok, ich habe das jetzt folgendermaßen versucht zu lösen:
xmlwrapper.h:
//---------------------------------------------------------------------------
#ifndef xmlwrapperH
#include <vcl.h>
#include <XMLDoc.hpp>
#define xmlwrapperH
//---------------------------------------------------------------------------
class XMLWrapper
{
public:
XMLWrapper();
~XMLWrapper();
void saveToFile(String);
void loadFromFile(String);
void addBackgroundImage(String);
String getBackgroundImage();
void addDesktopIcon(String, String, String, int, int);
void getDesktopIcons();
TStringList* iterateDesktopIcon(int);
void setUser(String, String);
TStringList* getUser();
void setScreenResolution(String, float);
TStringList* getScreenResolution();
void setPathToApplicationDir(String);
String getPathToApplicationDir();
void setScheduleAlign(bool);
bool isAlignAtSchedule();
int iconsCount;
TStringList *Next();
bool isEnd();
protected:
_di_IXMLNode config;
_di_IXMLNodeList icons;
int currentIconCount;
};
#endif
und Ausschnitte der Cpp Datei:
XMLWrapper::XMLWrapper()
{
TXMLDocument *lconfig = new TXMLDocument("");
//Zum einrücken der Daten
lconfig->Options = lconfig->Options << doNodeAutoIndent << doAutoSave;
//Aktivieren der Datei, wichtig zum Bearbeiten
lconfig->Active = true;
//Encodig einstellen. Umlaute lassen grüßen
lconfig->Encoding = "UTF-8";
//erstmal einen Licence-Kommentar erstellen:
_di_IXMLNode CNode = lconfig->CreateNode(L"File generated by Eggman Project. (c) 2009 - All rights reserved", ntComment, "");
lconfig->ChildNodes->Add(CNode);
//Rootknoten erstellen. Den gibt es nur einmal
lconfig->DocumentElement = lconfig->CreateElement(L"eggman", "");
this->config = lconfig->DocumentElement;
//Anzahl der eingelesenen Icons initialisieren
this->iconsCount = 0;
this->currentIconCount =0;
}
void XMLWrapper::saveToFile(String File)
{
String xml =this->config->GetXML();
TStringList *save = new TStringList();
save->Add(xml);
save->SaveToFile(File);
}
void XMLWrapper::loadFromFile(String File)
{
_di_IXMLDocument txd = LoadXMLDocument( File );
this->config = txd;
}
Das Funktioniert auch soweit. Wenn ich txd->GetXML(); ausführe gibt er mir das richtige zurück.
Nur wenn ich jetzt
_di_IXMLNode user = this->config->ChildNodes->GetNode(WideString("user"));
ausführe kommt die allseits bekannte und beliebte Fehlermeldung:
Im Projekt Priject1.exe ist eine Exception der Klasse EAccessViolation mit der Meldung 'Zugriffsverletzung bei Adresse 004031A4 in Modul 'Project1.exe'.Lesen von Adresse 000000000' aufgetreten.
Kann mir da jemand helfen?