pugixml

Use pugiXML to rename nodes based on a std::map

。_饼干妹妹 提交于 2019-12-06 09:54:50
问题 I'm new to C++ but I am trying to define a standard set of node names and then map to them. For example my standard import / output schema is this: <data> <entry> <id>1</id> <description>Test</description> </entry> </data> However sometimes my XML import will be named differently so I want to create a map so it still outputs in the above format, even if the input file has this naming convention: <data> <entry> <id>1</id> <content>Test</content> </entry> </data> This code is my best guess

Convert pugixml's result.offset to column/line

亡梦爱人 提交于 2019-12-05 14:14:25
I need user-friendly error reporting for an application that uses pugixml. I am currently using result.offset. Is there a way to get the line and column instead? I am potentially dealing with large XML files, if that makes a difference. This functionality is not readily available in pugixml since it's relatively expensive to do it on every parse, and after parsing is complete it's impossible to recover file/line information in the general case. Here's a snippet that builds an offset -> line mapping that you can use in case parsing fails or you need the information for other reasons; feel free

Use pugiXML to rename nodes based on a std::map

社会主义新天地 提交于 2019-12-04 15:39:01
I'm new to C++ but I am trying to define a standard set of node names and then map to them. For example my standard import / output schema is this: <data> <entry> <id>1</id> <description>Test</description> </entry> </data> However sometimes my XML import will be named differently so I want to create a map so it still outputs in the above format, even if the input file has this naming convention: <data> <entry> <id>1</id> <content>Test</content> </entry> </data> This code is my best guess based on the documentation and help I've got, but I have got stuck in trying to complete it: #include "pugi

Pugixml - parse namespace with prefix mapping and without prefix mappig

社会主义新天地 提交于 2019-12-04 04:52:24
问题 I have a client application that parses xml responses that are sent from 2 different servers. I call them server A and server B. Server A responds to one of the request with a response as below: <?xml version="1.0" encoding="UTF-8"?> <D:multistatus xmlns:D="DAV:"> <D:response> <D:href>/T12.txt</D:href> <D:propstat> <D:prop> <local-modification-time xmlns="urn:abc.com:webdrive">1389692809</local-modification-time> </D:prop> <D:status>HTTP/1.1 200 OK</D:status> </D:propstat> </D:response> </D

Build an xml tree from scratch - pugixml C++

社会主义新天地 提交于 2019-12-03 12:47:16
Firstly I would like to say that I have been using an XML parser written by Frank Vanden Berghen and recently trying to migrate to Pugixml. I am finding the transition bit difficult. Hoping to get some help here. Question: How can I build a tree from scratch for the small xml below using pugixml APIs? I tried looking into the examples on the pugixml home page, but most of them are hard coded with root node values. what I mean is if (!doc.load("<node id='123'>text</node><!-- comment -->", pugi::parse_default | pugi::parse_comments)) return -1; is hard-coded. Also I tried reading about xml

Pugixml - parse namespace with prefix mapping and without prefix mappig

℡╲_俬逩灬. 提交于 2019-12-02 02:16:44
I have a client application that parses xml responses that are sent from 2 different servers. I call them server A and server B. Server A responds to one of the request with a response as below: <?xml version="1.0" encoding="UTF-8"?> <D:multistatus xmlns:D="DAV:"> <D:response> <D:href>/T12.txt</D:href> <D:propstat> <D:prop> <local-modification-time xmlns="urn:abc.com:webdrive">1389692809</local-modification-time> </D:prop> <D:status>HTTP/1.1 200 OK</D:status> </D:propstat> </D:response> </D:multistatus> Server B responds to one of the request with a response as below: <?xml version="1.0"

How to convert pugi::char_t* to string

不想你离开。 提交于 2019-11-28 02:02:24
问题 Hi I'm using pugixml to process xml documents. I iterate through nodes using this construction pugi::xml_node tools = doc.child("settings"); //[code_traverse_iter for (pugi::xml_node_iterator it = tools.begin(); it != tools.end(); ++it) { //std::cout << "Tool:"; cout <<it->name(); } the problem is that it->name() returns pugi::char_t* and I need to convert it into std::string. Is it possible ?? I can't find any information on pugixml website 回答1: According to the manual, pugi::char_t is