XML 문서를 저장하기 전에 들여 쓰기하는 VBA 하위 문서를 작성했습니다. 들여 쓰기는 Visual Studio에서 포맷 할 때 나타나는 것과 비슷합니다. 어쩌면 하위 요소와 CDatas를 처리 할 수 있도록 확장되어야합니다. 코드에 대한
Sub IndentXml(xml As IXMLDOMElement, Optional depth As Integer)
If IsMissing(depth) Then
depth = 0
End If
Dim txt As IXMLDOMText
If Not (xml.OwnerDocument.DocumentElement Is xml) Then
Set txt = xml.OwnerDocument.createTextNode(vbNewLine & String(depth, vbTab))
xml.ParentNode.InsertBefore txt, xml
End If
Dim child As IXMLDOMNode
Dim hasElements As Boolean
hasElements = False
For Each child In xml.ChildNodes
If child.NodeType = NODE_ELEMENT Then
IndentXml child, depth + 1
hasElements = True
ElseIf child.NodeType = NODE_CDATA_SECTION Then
Set txt = xml.OwnerDocument.createTextNode(vbNewLine & String(depth + 1, vbTab))
xml.InsertBefore txt, child
hasElements = True
End If
Next
If hasElements Then
Set txt = xml.OwnerDocument.createTextNode(vbNewLine & String(depth, vbTab))
xml.appendChild txt
End If
End Sub
감사합니다. 다음 주에 시도해 보겠습니다. – HorusKol