Hi does someone know how to to query a attribute in to a string variable, using tinyxml2?
Example:
<pattern>
<distances numberOfDistances="1" realWorldPixelSize="0.26428571428571429">
<markerDistance linkName="AB" distance="58.624385902531891"/>
</distances>
</pattern>
To get the distance attribute I use
for (tinyxml2::XMLElement* child = distancesElement->FirstChildElement(); child != NULL; child = child->NextSiblingElement())
{
double distance;
child->QueryAttribute("distance", &distance);
distances.push_back(MarkerDistance(linkName, distance));
}
I thought for a string it would be something like this:
std::string linkName;
child->QueryAttribute("linkName", &linkName);
But for a string there seems to be no overload.
Ok, I found it.
Use:
const char * name
name = child->Attribute("linkName");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With