Dziś szuka sposobu jak wydobyć <!-- -->
z Visual Basic for Applications (nie C#), znalazłem też nodeTypeString własność, ale to zajmuje więcej miejsca. Oto przykład w 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
To omitts udokumentować najlepszymi nadrzędne komentarz węzły, ale mogą być pobierane bezpośrednio jakoś w razie potrzeby, na przykład za pomocą With xmldoc.documentElement.childNodes
.
Wydaje mi się to dobre. – Dave