• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录

cyz88

  • 博客园
  • 联系
  • 订阅
  • 管理

公告

View Post

Qt 删除节点

   QFilefile(path);

if(!file.open(QFile::ReadOnly|QFile::Text))
{
std::cerr<<"Error:Cannotreadfile"
<<qPrintable(path)
<<":"<<qPrintable(file.errorString())
<<std::endl;
}
QStringerrorStr;
interrorLine;
interrorColumn;
QDomDocumentdoc;
if(!doc.setContent(&file,false,&errorStr,&errorLine,
&errorColumn))
{
std::cerr<<"Error:Parseerroratline"
<<errorLine<<","
<<"column"<<errorColumn<<":"
<<qPrintable(errorStr)<<std::endl;
}
file.close();
QDomElementroot=doc.documentElement();
QDomNodechild=root.firstChild();
while(!child.isNull())
{
if(child.toElement().tagName()=="xxxx_cfg")
{
       QDomElementel=child.toElement();
QDomNodenodebChild=el.firstChild();
while(!nodebChild.isNull())
{
if(nodebChild.toElement().tagName()=="xxx_name")
{
if(nodebChild.toElement().text()==entityName)
{
root.removeChild(child);
break;
}
nodebChild=nodebChild.nextSibling();
}
else
{
nodebChild=nodebChild.nextSibling();
}
}
  child=child.nextSibling();
}
else
{
     child=child.nextSibling();
 }
}

QFilef(path);
if(!f.open(QFile::WriteOnly|QFile::Text))
{
std::cerr<<"Error:Cannotreadfile"
<<qPrintable(path)
<<":"<<qPrintable(f.errorString())
<<std::endl;

}

QTextStreamout(&f);
root.save(out,4);
}

posted on 2012-09-26 16:30  cyz88  阅读(315)  评论(0)    收藏  举报

刷新页面返回顶部
 
博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3