Aujourd'hui, la recherche de la façon comment extraire <!-- -->
à partir de Visual Basic pour Applications (non C#), je l'ai trouvé aussi nodeTypeString propriété, mais il faut plus d'espace. Voici un exemple en VBA:
Dim xmldoc As New MSXML2.DOMDocument30
Dim oNodeList As IXMLDOMSelection
Dim node As IXMLDOMNode
Dim i As Long
Dim FileName As String, FileName1 As String
FileName = "..." ' Source
FileName2 = "..." ' Target
xmldoc.async = False ' ?
xmldoc.Load FileName
If (xmldoc.parseError.errorCode <> 0) Then Exit Sub ' or Function
Set oNodeList = xmldoc.selectNodes("//*") '' all nodes
For i = 0 To oNodeList.length - 1
With oNodeList(i)
For Each node In .childNodes
If node.nodeTypeString = "comment" Then .removeChild node
Next
End With
Next
xmldoc.Save FileName2
Set oNodeList = Nothing ' ?
Set xmldoc = Nothing
Il omitts document Haut nœuds de commentaires des parents, mais ils peuvent être récupérés en quelque sorte directement en cas de besoin, par exemple en utilisant With xmldoc.documentElement.childNodes
.
Ça me semble bon. – Dave