I've encountered a problem that I'm not being able to solve using tinyxml2.
I have a function that receives as a parameter a XMLElement and I need to iterate over its attributes. With tinyxml, this worked:
void xmlreadLight(TiXmlElement* light){
for (TiXmlAttribute* a = light->FirstAttribute(); a ; a = a->Next()) {
//Do stuff
}
}
Using the same with tinyxml2, like in the example below, I get the following error:
a value of type
const tinyxml2::XMLAttribute *cannot be used to initialize an entity of typetinyxml2::XMLAttribute *
void xmlreadLight(XMLElement* light){
for (XMLAttribute* a = light->FirstAttribute(); a ; a = a->Next()) {
//Do stuff
}
}
The XML code in question is:
<lights>
<light type="POINT" posX=-1.0 posY=1.0 posZ=-1.0 ambtR=1.0 ambtG=1.0 ambtB=1.0 />
</lights>
where light is the XMLElement passed into the function xmlreadLight. Not sure if my question is properly set up, so if theres some info missing, let me know.
Going by the error message, it looks like you need to do:
Presumbably, the return type of
FirstAttributehas been madeconstin tinyxml2.If you check the Github repository for the
tinyxml2.hfile on line 1513 you will see this: