您是否有人知道如何使用tinyxml2?
查询字符串变量中的属性示例:
<pattern>
<distances numberOfDistances="1" realWorldPixelSize="0.26428571428571429">
<markerDistance linkName="AB" distance="58.624385902531891"/>
</distances>
</pattern>
要获取我使用的距离属性
for (tinyxml2::XMLElement* child = distancesElement->FirstChildElement(); child != NULL; child = child->NextSiblingElement())
{
double distance;
child->QueryAttribute("distance", &distance);
distances.push_back(MarkerDistance(linkName, distance));
}
我想要一个字符串,就像这样:
std::string linkName;
child->QueryAttribute("linkName", &linkName);
但是对于一个字符串似乎没有过载。
答案 0 :(得分:5)
好的,我找到了。
使用:
const char * name
name = child->Attribute("linkName");