Parsing attribute with numeric value "1 2" does not produce an error.
If an attribute contains a numeric value with spaces like "1 2" and you use the parse to double you get the value 1. I would expect this to return an error. Is this the intended behavior?
Hi @Levi-Armstrong , which version and API did you use?
I use the double XMLElement::DoubleAttribute(const char* name, double defaultValue) const
in the master branch, but it seems the result is not the same as you descripe. I write an attribute contains a numeric value with spaces like "1 2" in an XML file as you descripe, but i got 1 rather than 12.
Can you give more detail or code snippet about you issue?
My mistake, I also get 1. Is this the expected behavior? I would still expect if the whole string is not a numeric value it would fail. I am not sure what is used to parse double from strings, but the code below produces my expected behavior.
std::stringstream ss;
ss.imbue(std::locale::classic());
ss << s;
double out;
ss >> out;
if (ss.fail() || !ss.eof())
return false;
return true;