qq_22099861 2015-04-30 03:36 采纳率: 0%
浏览 1519

如何删除rapidxml一行属性,求别拿网址 我贴代码 你教教我

#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 FindFile(char * lpPath, vector &vec)
{
char strTemp[255];
char szFind[255];
char temp[255];
string str = "";
WIN32_FIND_DATA FindFileData;

strcpy(szFind,lpPath);
strcpy(temp,lpPath);
strcat(szFind,"\\*.*");

HANDLE hFind=::FindFirstFile(szFind,&FindFileData);
if(INVALID_HANDLE_VALUE == hFind)    return;
cout<<"遍历放入vec中的路径名字:"<<endl;
while(TRUE)
{
    if(FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
    {
        if(FindFileData.cFileName[0]!='.')
        {
            strcpy(szFind,lpPath);
            strcat(szFind,"\\");
            strcpy(temp,lpPath);
            strcat(temp,"\\");
            strcat(szFind,FindFileData.cFileName);
            FindFile(szFind,vec);
        }
    }
    else
    {
        strcpy(strTemp,temp);
        strcat(strTemp,"\\");
        strcat(strTemp,FindFileData.cFileName);
        str = FindFileData.cFileName;
        if(str.find_first_of(".") > 0)
        {   
            str = str.substr(str.find_last_of(".") + 1,str.length());
            if(str == "xml")
            {
                vec.push_back(strTemp);
                cout<<strTemp<<endl;
            }
        }           
    }
    if(!FindNextFile(hFind,&FindFileData))   
    break;
}
FindClose(hFind);

}

void getInfo(string strFileName,vector &vec)
{
fstream infile;
string temp = "";
string publish = "";
string::size_type loc;
infile.open(strFileName.c_str());
if(infile.fail())
{
cout << "can not open the file";
}
while(!infile.eof())
{
getline(infile,temp);
loc = temp.find("PublishData");
if(loc != string::npos)
{
publish = temp.substr(loc + 13,1);
if(publish == "1")
{
vec.push_back(temp);
cout<<temp<<endl;
}
}
}
}

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<char> 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的属性全部剔除。请问如何做。例子:
xxxxx.xml





我如何剔除publishdata=0的一行属性。然后最后保存的时候只有publishdata=1的数据

  • 写回答

1条回答 默认 最新

  • qq_28073533 2015-05-10 01:33
    关注

    我很想帮你,不过我不知道

    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?