B
Bryan
If I have the following string from a huge xml file:
std::string s = "<input key1=\"v1\" key2=\"val4\" key3=\"test\" />";
I need to get the values associated with the keys out from this line.
What is the best way to do this? I was looking at sscanf, and
std::string find, but this seems kind of brute force to find the key,
get the pos, increment by 2 (for the = and first ") then grab everything
up to the next ". But maybe this is the best approach?
Is there a pretty way to have a small function that does this:
void GetValFromKey(std::string& input, std::string& key, std::string&
value)
{
std::string val;
// find val from key
value = val;
}
std::string s = "<input key1=\"v1\" key2=\"val4\" key3=\"test\" />";
I need to get the values associated with the keys out from this line.
What is the best way to do this? I was looking at sscanf, and
std::string find, but this seems kind of brute force to find the key,
get the pos, increment by 2 (for the = and first ") then grab everything
up to the next ". But maybe this is the best approach?
Is there a pretty way to have a small function that does this:
void GetValFromKey(std::string& input, std::string& key, std::string&
value)
{
std::string val;
// find val from key
value = val;
}