[C/C++] TinyXML Attribut-Werte extrahieren

Hallo zusammen,

ich habe mit TinyXML eine XML Konfiguration angelegt.

Beispiel:
Code:
#include <iostream>
#include <cstdlib>
#include "tinyxml/tinyxml.h"
#include "tinyxml/tinyxml.cpp"
#include "tinyxml/tinyxmlerror.cpp"
#include "tinyxml/tinyxmlparser.cpp"
#include "tinyxml/tinystr.cpp"
#include "tinyxml/tinystr.h"
#include <string>
using namespace std;

int main() {

//##########      Beginn TinyXML

	TiXmlDocument doc;  
	TiXmlDeclaration * decl = new TiXmlDeclaration("1.0", "ISO-8895-1", "");
	doc.LinkEndChild( decl );  

//##########      RootElement

	TiXmlElement * root = new TiXmlElement("config");  
	doc.LinkEndChild( root );  

//##########      Kommentar

	TiXmlComment * comment = new TiXmlComment();
	comment->SetValue("Config-File");  
	root->LinkEndChild(comment);  

//##########      ConfigElemente

	TiXmlElement * cxn = new TiXmlElement("Connection");  
	root->LinkEndChild(cxn);  
	cxn->SetAttribute("ip", "192.168.0.1");
	cxn->SetDoubleAttribute("timeout", 123.456); // floating point attrib

	doc.SaveFile("cfg.xml");

//##########      Ende TinyXML

// ...

  return 0;                                                               
}

mein Problem ist, WIE kann ich jetzt die Werte der Attribute wieder auslesen um sie z.B. zu überprüfen und ggf auszutauschen?

TinyXML Doku --> http://www.grinninglizard.com/tinyxmldocs/index.html

in der doku hab ich diverse methoden gefunden aber davon hat nichts wirklich zum Erfolg geführt...

hat von euch schon jemand was mit TinyXML gemacht?

Danke im Voraus!
 
Anmerkung am Rande:
Code:
#include "tinyxml/tinyxml.cpp"
#include "tinyxml/tinyxmlerror.cpp"
#include "tinyxml/tinyxmlparser.cpp"
#include "tinyxml/tinystr.cpp"
Sicher, dass das so stimmt? ?.o

Versuch's mal so:
Code:
TiXmlDocument doc2( "cfg.xml" );
	doc2.LoadFile();

Stand übrigens in der Doku :)
Und wenn's bei dir nicht zum Erfolg geführt hat, musst du was falsch gemacht haben.
 
klar stimmt das, sonst würds wohl nicht funzen...

das steht auch in der Doku:
To Use in an Application:

Add tinyxml.cpp, tinyxml.h, tinyxmlerror.cpp, tinyxmlparser.cpp, tinystr.cpp, and tinystr.h to your project...

btw.

mit

Code:
doc.LoadFile("cfg.xml");
lad ich die datei in den Hauptspeicher

die Adresse eines Elementes soll ich über die funktion:
Code:
int TiXmlElement::QueryIntAttribute(const char *  name, int *  _value) const
bekommen (sofern ich das richtig verstanden habe), und diese Methode richtig zu nutzen bin ich scheinbar nicht in der Lage ...




@EDIT: Hat sich erledigt... habs hinbekommen dennoch danke an dietox!
 
Zurück
Oben