开发者

How to iterate an xml file and store it in map

How to iterate an file using rapidXml and store it in a map... Something like creating a dictionary using the contents of file. I have tried this but i can get only开发者_高级运维 the first level of key-value pairs not the inner levels.

typedef map <string, string> MapType;
  MapType                 mProfiles;
        mXmlDocument.parse<parse_full>(&xml_copy[0]);

        for (xml_node<> *node = mXmlDocument.first_node();
             node; node = node->next_sibling())
        {
            mProfiles[node->name()] = node->value();
        }


Besides the value of the node, also examine the type. If the type is rapidxml:::node_element or rapidxml:::node_document it may have children.

See the member function rapidxml::print_node in rapidxml_print.hpp.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜