0

您好我在从 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”没有问题

我究竟做错了什么?

4

1 回答 1

0

这是我在文档中找到的。可能无法工作,因为我没有 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
于 2016-01-19T07:10:04.160 回答