Code: Select all
<element_position id1="152722522" id2="3" x="301" y="118" />
It reads id2, x, and y just fine, but returns 152722528 instead of 152722522 for id1. (If I just use getAttributeValue to get the string, it correctly returns 152722528). I suspect that this is because getAttributeValueAsFloat is used and thus some rounding errors are occurring. id1 is an id and needs to be exact or my program crashes.
This is what I use as a workaround for now:
Code: Select all
#include <sstream>
template<typename T>
T getAttributeValueAs(IXMLReader* xml, const wchar_t* attribute)
{
stringc valueString = xml->getAttributeValue(attribute);
if (valueString.size() <= 0) return ~0;
stringstream valueStream;
valueStream << valueString.c_str();
T value = ~0;
valueStream >> value;
return value;
}