Plist analysis, simple implementation.

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.