首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > XML SOAP >

[XML处置]_[使用libxml2的xpath特性修改xml文件内容]

2012-11-26 
[XML处理]_[使用libxml2的xpath特性修改xml文件内容]场景:1.在软件需要保存一些配置项时,使用数据库的话比

[XML处理]_[使用libxml2的xpath特性修改xml文件内容]

场景:

1.在软件需要保存一些配置项时,使用数据库的话比较复杂,查看内容也不容易.纯文本文件对utf8字符支持也不好.

2.这时候使用xml是最佳选择,使用跨平台库libxml2。

3.基于xpath的保存方式对保存局部内容非常方便。

4.参考例子xpath2.c

5.实际耗时: 2小时.


文件1: Makefile

<?xml version="1.0" encoding="UTF-8"?><doc>  <parent>    <discarded info="info attri">discarded</discarded>    <preserved/>    This text node must be discarded    <discarded>change second discarded text 中文</discarded>    <preserved>      content1      <child1/>      <child2>content2</child2>      <preserved>too</preserved>      <child2>content3</child2>      <preserved/>      <child2>content4</child2>      <preserved/>      <child2>content5</child2>      content6    </preserved>  </parent></doc>





热点排行