遍歷xml刪選 如何刪除篩選中的xml的一行屬性。

2021-10-20 03:28:12 字數 1729 閱讀 8057

用的是rapidxml,如何去掉一行關鍵字為publishdata=0的屬性。最好**告訴我。#include#include#include#include#include#include#include"rapidxml/rapidxml.hpp"#include"rapidxml/...

用的是rapidxml,如何去掉一行關鍵字為publishdata=0的屬性。最好**告訴我。

#include

#include

#include

#include

#include

#include

#include "rapidxml/rapidxml.hpp"

#include "rapidxml/rapidxml_iterators.hpp"

#include "rapidxml/rapidxml_print.hpp"

#include "rapidxml/rapidxml_utils.hpp"

using namespace std;

void loadinfo(string strfilename)

fstream infile;

string temp = "";

string publish = "";

string::size_type loc;

infile.open(strfilename.c_str());

while(!infile.eof())

getline(infile,temp);

loc = temp.find("publishdata");

if(loc != string::npos)

publish = temp.substr(loc + 13,1);

if(publish == "0")//已經找到所有pubdata=0的情況,如何利用rapidxml.attribute時問題所在

rapidxml::xml_document xmldoc;

rapidxml::xml_node<>* root = xmldoc.first_node();

//問題在這裡 。在這裡如何做東西!!!!!

void main()

vector s;

vector vec;

//findfile("e:\work\game",s);

findfile("f:\test",s);

vector::iterator it;

for(it = s.begin();it!= s.end();it++)

string filepath = *it;

file *pfile = fopen(filepath.c_str(),"a+");

if(pfile)

//getinfo(filepath.c_str(), vec);

loadinfo(filepath.c_str());

fclose(pfile);

system("pause");

//將儲存在容器中的位址。乙個個開啟進型行標記查詢

q:問題部分我已經「//」貼出來了,問題是我已經把所有xml檔案位址遍歷了,然後刪選關鍵字,想把所有publishdata=0的屬性全部剔除。請問如何做。例子:

***xx.xml

我如何剔除publishdata=0的一行屬性。然後最後儲存的時候只有publishdata=1的資料,因為**太長就之貼出來問題的所在地方。

展開

foreach動態刪除控制項漏刪 遍歷不全

foreach control a in picturebox1.controls 在使用 動態刪除控制項時,會導致遍歷不全漏刪的情況。關鍵是這段 可能不會報錯,簡直坑爹。錯誤原因在 foreach迴圈中不能修改集合元素的值 當remove乙個控制項後,剩下控制項的索引會發生變化。解決方法 1.使用...

ajax和php刪除 php ajax如何刪除資料

php ajax刪除資料的方法 首先在php檔案中接收get引數,並根據引數刪除資料 然後使用函式 json encode 將資料返回 接著在前端使用ajax請求該檔案即可。首先在php檔案中接收get引數,並根據引數刪除資料 id get id 刪除資料邏輯 json decode code 1,...

Python 遍歷列表刪除操作時不能正確刪除

發現元素間隔進行了刪除,這是什麼情況導致的呢?總結當我們遍歷列表中的元素進行刪除操作的時候,發現並不能滿足我們的需求 ls 1 2,3 4,5 for i in ls if i 1 ls.remove i ls 1 3,5 列表的長度變短,對最初的遍歷長度做了修改,導致超出索引 ls 1 2,3 4...