⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readme

📁 在Linux C++中解析XML文件 能够创建文件
💻
字号:
== Program structure ==README   <--readme file.*xml     <--header and cpp files of XML Parser.*test    <--testing code.== Known issues and limitations ==1, When program starts up, you need to do the following things:log4cpp::PropertyConfigurator::configure("log4cpp.conf");2, Can only process the xml file encoded with "UTF-8".3, To create an xml file, you need to do as follows:xmlDocPtr doc = xmlNewDoc(BAD_CAST"1.0");xmlNodePtr root_node = xmlNewNode(NULL,BAD_CAST"root");xmlDocSetRootElement(doc,root_node);			xmlNodePtr node = xmlNewNode(NULL, BAD_CAST "Printers");xmlAddChild(root_node,node);						xmlNodePtr printer1 = xmlNewNode(NULL, BAD_CAST "Printer1");xmlAddChild(node,printer1);xmlNodePtr port1 = xmlNewNode(NULL, BAD_CAST "Port");xmlNodePtr port1_content = xmlNewText(BAD_CAST"123");xmlAddChild(printer1,port1);xmlAddChild(port1,port1_content);xmlNewProp(port1,BAD_CAST"name",BAD_CAST "Port1");xmlSaveFormatFileEnc("XPathConfig.xml",doc,"UTF-8",1);4, To open an xml file, please follow:CXMLConfig* xmlConfig = CXMLConfig::Open("XPathConfig.xml");...delete xmlConfig;5, To get the leaf value of an xml file, please follow:string port1 = xmlConfig->GetFieldValueByPath("/root/Printers/Printer1/Port");6, To set the leaf value of an xml file and save it, please follow:xmlConfig->SetFieldValueByPath("789","/root/Printers/Printer1/Port");xmlConfig->Save();7, To remove one node of an xml file and save it, please follow:xmlConfig->Remove("/root/Printers/Printer3");== Compile and Run ==1, install package of cppunit, log4cpp to support unit testing and log.2, run tar -xzvf libxml2-2.6.30.tar.gz to extract package of libxml2and then run ./configure;make;make install. 3, run tar -xzvf xmlparser-1.0.tar.gz to extract xml parser package.4, run ./configure;make to generate library named "libxmlparser.a"which can be used in your client program and then run testing script.Finally, the result report is generated.5, run make clean to clean generated files and ./dist.sh to generate distribution package. 6, the result report is as follows:Davis::XMLParserTestCase::testOpen2009-03-12 15:25:44,752 [INFO] - Save xml file successfully. : OKDavis::XMLParserTestCase::testGetFieldValueByPath2009-03-12 15:25:44,753 [INFO] - Save xml file successfully.  : OKDavis::XMLParserTestCase::testSave2009-03-12 15:25:44,754 [INFO] - Save xml file successfully.  : OKDavis::XMLParserTestCase::testRemove2009-03-12 15:25:44,756 [INFO] - Save xml file successfully.  : OKOK (4)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -