Source
1 classXml {2 Public:3typedef std::p air<std::wstring, std::wstring>Nodet;4 StaticStd::vector<nodet> Parse (ConstStd::wstring &XML)5 {6Std::vector<nodet>result;7 8 intStackcount =0;9 std::wstring TagName;Ten Std::wstring::const_iterator OneCuriter =std::begin (XML), ABegiter = Std::end (XML), Enditer =std::end (XML), -Cbegiter = Std::end (XML), Cenditer =std::end (XML); - the Std::wsmatch Smatch; - while(Std::regex_search (Curiter, Std::end (XML), Smatch, Std::wregex (LR"(</\w+>|<\w+>)"))) - { - if(Stackcount = =0) + { -Begiter = smatch[0].first; +Cbegiter = smatch[0].second; ATagName = Std::regex_replace (smatch[0].str (), Std::wregex (LR"(< (\w+) >)"), LR"($)"); at } - -Curiter = smatch[0].second; - if(smatch[0].str (). substr (1, tagname.size ()) = =tagName) -++Stackcount; - Else if(smatch[0].str (). substr (2, tagname.size ()) = =tagName) in--Stackcount; - to //the match is complete. + if(Stackcount = =0) - { theEnditer = smatch[0].second; *Cenditer = smatch[0].first; $ Panax Notoginseng Result.push_back (Std::make_pair (TagName, std::wstring (Cbegiter, Cenditer))); - } the } + returnresult; A }; the};
Because the project needs input, output the plist file.
The C + + standard does not have an XML library. Simply write a simple version of yourself.
Features are quite limited and only supports parsing of each label content.
But it's enough for me.
The code is not too long to use.
SUBSTR can be optimized out ...
Plist analysis, simple implementation.