[英]How to remove nodes from a xml doc in VBA
嗨,我無法從XML文檔中刪除節點。
例如:
<XML>
<Node1>xxx</Node1>
<Node2>
<Node3>zzz</Node3>
<Node4>RemoveThis</Node4>
</Node2>
<Node2>
<Node3>zzz</Node3>
<Node4>RemoveThis</Node4>
</Node2>
</XML>
我正在使用這樣的代碼:
If oXml.ChilkatPath("Node1|*") = "xxx" Then
oXml.RemoveChildWithContent("Node2|Node4|*")
outFile.WriteLine(oXml.GetXml())
End If
如果我用
oXml.ChilkatPath("Node2|Node4|*")
獲取值“ RemoveThis”沒有問題
我究竟做錯了什么?
這是我在文檔中找到的內容。 可能沒有用,因為我沒有Chilkat。
Set xBeginAfter = xml.GetSelf()
' xFound is a Chilkat_9_5_0.Xml
if xml.ChilkatPath("Node1|*") = "xxx" then
Set xFound = xml.SearchAllForContent(xBeginAfter,"Remove This")
Do While Not (xFound Is Nothing )
xFound.RemoveFromTree
Set xFound = xml.SearchAllForContent(xBeginAfter,"Remove This")
Loop
end if
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.