5

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.

4

1 回答 1

8

好的,我找到了。

利用:

const char * name
name = child->Attribute("linkName");
于 2015-11-27T16:46:39.430 回答