pukemiketukas
June 5th, 2008, 08:49 AM
Ok. I'm developing small c++ program which should parse my xml files. This is a part of the script:
string xmlData = "test<sessionTest>10</sessionTest>test";
boost::regex pat("(.*)<sessionTest>(.*)</sessionTest>(.*)");
boost::smatch matches;
if (boost::regex_match(xmlData, matches, pat))
cout << matches[2] << endl;
And the script return me 10, but I need to assign matches[2] to an integer variable. How I can do that. I try to assign directly and with atoi() but i'v got no lucky so far.
I'm using linux boost_regex library.
Ps: is there any better way to write pattern in c++ to parse data inside <sessionTest>?
Thanks in advance...
string xmlData = "test<sessionTest>10</sessionTest>test";
boost::regex pat("(.*)<sessionTest>(.*)</sessionTest>(.*)");
boost::smatch matches;
if (boost::regex_match(xmlData, matches, pat))
cout << matches[2] << endl;
And the script return me 10, but I need to assign matches[2] to an integer variable. How I can do that. I try to assign directly and with atoi() but i'v got no lucky so far.
I'm using linux boost_regex library.
Ps: is there any better way to write pattern in c++ to parse data inside <sessionTest>?
Thanks in advance...