修改和删除xml文件中的元素 [英] modify and remove elements from the xml file

查看:88
本文介绍了修改和删除xml文件中的元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



如何从xml文件中删除或修改元素或节点.

我使用了CMarkup类,其中removeelem()和removenode()不起作用.
任何建议.



how to remove or modify elements or node from an xml file.

i used the CMarkup class where removeelem() and removenode() is not working.
any suggestions.

推荐答案

此示例显示如何删除当前父位置下的所有元素.
This example shows how to remove all of the elements under the current parent position.
CMarkup xml;
xml.Load (MCD_T("myfile.xml"));
....
xml.ResetMainPos();
while ( xml.FindElem() )
  xml.RemoveElem();


RemoveNode删除当前主要位置的节点.如果没有要删除的主要位置,则它返回false,并且不修改CMarkup对象.
也许您尝试删除当前处于不良位置的节点?


RemoveNode removes the node at the current main position. If there is no main position to remove, it returns false and does not modify the CMarkup object.
Maybe you try to remove node at the current bad position ?


我对XML的经验很少,但是我可以告诉您使用Microsoft的MSXML库很容易. msds中的示例很少,但是主要思想是使用诸如selectSingleNode,childNodes,getAttribute之类的功能.
I have little experience with XML but i can tell you its easy with the Microsoft''s libraries MSXML . There are few examples in msds but the main idea is using functions like selectSingleNode , childNodes, getAttribute and so on.


^ ]是一个简单的C ++的xml库.它是开源和跨平台的.不能处理验证(DTD,XSL)和xml名称空间等高级功能,但是大多数时候不需要这些功能.
TinyXml[^] is a simple drop in xml library for c++. It''s opensource and crossplatform. Doesn''t handle advances features like validation (DTD, XSL) and xml namespaces but those features aren''t needed most of the time.


这篇关于修改和删除xml文件中的元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆