如何在ROS环境中使用POCO库编写XML
How can write XML with POCO library in ROS environment
我想创建C 程序,该程序使用POCO库读写XML。
所以,我写了简单的程序。
我可以阅读每个XML元素。
,但我无法编写新的XML元素。
下面是test.xml。
<config>
<prop1>value1</prop1>
</config>
这是我的代码。
#include <iostream>
#include <string>
#include <Poco/AutoPtr.h>
#include <Poco/Util/XMLConfiguration.h>
using Poco::AutoPtr;
using Poco::Util::XMLConfiguration;
int main(int argc, char const* argv[])
{
AutoPtr<XMLConfiguration> pConf(new XMLConfiguration("test.xml"));
std::string prop1 = pConf->getString("prop1");
std::cout << "prop1 = " << prop1 << std::endl;
pConf->setString("prop2", "input");
pConf->save("test.xml");
return 0;
}
运行此程序后,我希望XML文件如下。
<config>
<prop1>value1</prop1>
<prop2>input</prop2> <--New element added!!
</config>
,但结果如下。
<config>
<prop1>value1</prop1>
</config>
什么都没有改变...
我在做什么错?
预先感谢。
添加了如下
的信息- OS :: Linux Mint18.1
- Poco Library版本:: 1.7.6(从源代码构建)
- 构建系统:: cmake and Make and gcc
我运行以下命令。
sudo apt-get remove ros-kinetic-desktop-full
然后,我可以使用上述程序编写XML文件。
我认为ROS使用Poco库,它重复了我的Poco库。
所以我尝试将Poco Library(ROS)替换为Poco Library(Mine)。
我的尝试很好!
解决方案如下
如果您可以读取XML文件并且不能使用POCO库编写XML文件。
您的Poco库和ROS的Poco库可能会重复。
尝试以下命令。
-
安装ros
sudo apt-get安装ros-kinetic-desktop-full
-
用重新安装Poco库>目标前缀 to/usr/lib和/usr/include
./configure - prefix =/usr
make
sudo make install
相关文章:
- Cppcheck生成xml转储文件
- POCO::PostgreSQL:如何将std::vector支持添加到`Binder::bind`
- 如何在pugixml中获取节点的内部XML
- 如何使用tinyxml2从XML加载父实体和子实体
- boost xml parsingl将xml的路径作为变量发送
- C++RapidXml-使用first_node()遍历以修改XML文件中节点的值
- 使用 Tinyxml 在 xml 中添加一个子子项
- 增强基于 XML class_id的反序列化
- Poco FindMySql.cmake 无法找到 MySQL 源代码
- 在 c++ 中使用 vtd-xml 时,如何摆脱 EOFException?
- 防止在C++中选择错误文件时提升 xml 解析器崩溃
- c++ 读取 xml 文件的内容
- 删除 XML 文件中的子节点C++
- 使用 RapidXML 更新C++中的 XML 节点和属性值
- 在Cmake构建CmakeList.txt中读取/解析XML文件
- 从 XML 中读取未指定结构的每个数据成员
- 如何在ROS环境中使用POCO库编写XML
- 'class Poco::XML::Element'没有名为'getNodeByPath'的成员
- POCO 如何发送 XML 数据
- POCO C++SAX解析器:如果xml文档编码是ANSI,那么下一条语句不是读取并抛出编码错误异常