![]() |
xml parsen mit tinyxml
Ich komme auf keinen grünen zweig. :oops:
Ich habe eine einfache XML die ich mit tinyxml parsen will mein Problem ist das ich leider nicht sehr weit komme. XML ist angehängt!
Code:
GetText geht ins leere
TiXmlDocument document(Lng->szTemp);
document.LoadFile(); TiXmlHandle docHandle( &document ); TiXmlElement* child2 = docHandle.FirstChild( "configuration" ).FirstChild( "section" ).Child( "setting", 1 ).ToElement(); if ( child2 ) { const char* sDesc = child2->GetText(); }; Ich komme nicht auf die Section "SettingsDialog! Um anschließend über while oder ne For schleife die einzelnen Values auszulesen. kann jemand helfen.. gruss |
AW: xml parsen mit tinyxml
Noch nie jemand verwendet der eventuell helfen könnte?
gruss |
AW: xml parsen mit tinyxml
Ich habe jetzt mal eine XML erstellt die so aufgebaut ist wie eine INI-Datei.
Code:
Mein Problem ist nun wie lese ich die wieder ein.
tinyxml2::XMLDocument doc;
tinyxml2::XMLDeclaration * xdeclaration = doc.NewDeclaration(); xdeclaration->SetValue("xml version=\"1.0\" encoding=\"UTF-8\""); doc.InsertFirstChild(xdeclaration); // first entry tinyxml2::XMLElement *xdocument = doc.NewElement("configuration"); tinyxml2::XMLNode *xndocument = doc.InsertAfterChild(xdeclaration, xdocument); // Section tinyxml2::XMLElement* xeSection = doc.NewElement("section"); xeSection->SetAttribute("name", "SettingsDialog"); // Settings tinyxml2::XMLElement *xeSettings = doc.NewElement("settings"); // enumerate Line count from sTextSettingDialog for(int i=0; i < MAX_SETTINGSDIALOG_STRINGS; i++) { // convert integer(i) to string std::string s = std::to_string(i); char const *pchar = s.c_str(); // copy string buffer to *char char *buffer = new char[s.length()]; strcpy(buffer,s.c_str()); // using buffer for next element xeSettings = doc.NewElement(buffer); // New Settings Line xeSettings->SetValue("setting"); // First Attribut for Line(i) xeSettings->SetAttribute("name", buffer); // Attribute Value for Line(i) xeSettings->SetAttribute("value", sTextSettingDialog[i]); // End Line(i) xeSection->InsertEndChild(xeSettings); } // close Document xdocument->InsertEndChild(xeSection); // save document file doc.SaveFile("English.xml"); Es gibt nicht wirklich gute Dokumentationen dazu Wie komme ich an die Attribute ran? Das Dokument sieht dann so aus gruss |
Alle Zeitangaben in WEZ +1. Es ist jetzt 01:04 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