2010-10-08 18 views
2

Comment puis-je parse ce qui suit dans TinyXML:Parsing <multi_path littérale = "not_measured" /> dans TinyXML

<multi_path literal="not_measured"/> 

Je suis capable d'analyser facilement la ligne ci-dessous:

<hello>1234</hello> 

Le problème est que la première déclaration n'est pas analysée de façon normale. S'il vous plaît suggérer comment s'y prendre.

+2

Vous devez être plus explicite: ce qui ne « ne s'analysé la ** normal ** façon "signifie? – ereOn

Répondre

2

pas à 100% sûr de ce que vous êtes question est de demander, mais voici un format de base boucle aussi dans les fichiers XML à l'aide TinyXML:

/*XML format typically goes like this: 
<Value atribute = 'attributeName' > 
Text 
</value> 
*/ 
TiXmlDocument doc("document.xml"); 
bool loadOkay = doc.LoadFile(); // Error checking in case file is missing 
if(loadOkay) 
{ 
    TiXmlElement *pRoot = doc.RootElement(); 
    TiXmlElement *element = pRoot->FirstChildElement(); 
    while(element) 
    { 
     string value = firstChild->Value(); //Gets the Value 
     string attribute = firstChild->Attribute("attribute"); //Gets the attribute 
     string text = firstChild->GetText(); //Gets the text 
     element = element->NextSiblingElement(); 
    } 
} 
else 
{ 
    //Error conditions 
} 
+0

Comment obtenez-vous l'attribut TINYXML2 si vous ne connaissez pas son nom? – Michele