如何使用OmniXML删除子节点? [英] How to delete a child node using OmniXML?
本文介绍了如何使用OmniXML删除子节点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想删除行路径
部分中带有 pathid = 2
的行...
I'd like to delete the line with pathid="2"
in the rowpath
section...
<?xml version="1.0" encoding="utf-8"?>
<LostPath Condition="Active" Selected="train.exe" FullPathOfSelected="D:\mygames\arcade\train\" Selected="0">
<rowdir Name="train.exe" GamePath="D:\mygames\arcade\train\" Selected="0" />
<rowdir Name="othelo.exe" GamePath="D:\mygames\arcade\othello\" Selected="3"/>
<rowpath Name="train.exe" PathId="1" LevelPath="D:\mygames\arcade\train\levelpack1" levelsFound="27" />
<rowpath Name="train.exe" PathId="2" LevelPath="D:\mygames\arcade\train\levelpack21" levelsFound="19" />
<rowpath Name="othelo.exe" PathId="0" LevelPath="D:\mygames\arcade\othelo\levelpack1" levelsFound="11" />
</LostPath>
我该怎么做?
推荐答案
尝试使用此功能。
uses
OmniXML, OmniXMLUtils;
procedure TForm1.Button1Click(Sender: TObject);
var
XMLNode: IXMLNode;
XMLDocument: IXMLDocument;
begin
XMLDocument := CreateXMLDoc;
if XMLLoadFromFile(XMLDocument, 'XMLFile.xml') then
begin
XMLNode := XMLDocument.SelectSingleNode('/LostPath');
DeleteNode(XMLNode, 'rowpath[@PathId="2"]');
XMLDocument.Save('XMLFile.xml');
end;
end;
这篇关于如何使用OmniXML删除子节点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文