xml notepad命令行开关

时间:2014-05-12 16:27:02

标签: xml vb6

我想在XML Notepad 2007中打开一个XML文件,并使用命令行从批处理文件或VB6函数以不同的名称保存它。此操作的目的是将每个XML元素放在自己的行上,这是进一步数据处理所需要的。 我已经找到了如何在XML Notepad 2007中打开文件,但找不到任何有关执行" SaveAs"的开关/参数的信息。该文件。

1 个答案:

答案 0 :(得分:1)

您可以使用MSXML在VB6中自己执行此操作。这是一个小型演示:

screenshot

Option Explicit

Private Sub ManageUI()
    'Make UI changes based on the relationships of controls and their
    'current values.
    chkStandalone.Enabled = chkOmitXMLDeclaration.Value <> vbChecked
End Sub

Private Sub chkOmitXMLDeclaration_Click()
    ManageUI
End Sub

Private Sub cmdReformat_Click()
    Dim rdrCompact As MSXML2.SAXXMLReader
    Dim wrtFormatted As MSXML2.MXXMLWriter

    Set wrtFormatted = New MSXML2.MXXMLWriter
    With wrtFormatted
        .omitXMLDeclaration = chkOmitXMLDeclaration.Value = vbChecked
        .standalone = chkStandalone.Value = vbChecked
        .indent = chkIndent.Value = vbChecked
        .output = "" 'Tells MXXMLWriter we want Unicode String output.
        Set rdrCompact = New MSXML2.SAXXMLReader
        With rdrCompact
            Set .contentHandler = wrtFormatted
            Set .dtdHandler = wrtFormatted
            Set .errorHandler = wrtFormatted
            .putProperty "http://xml.org/sax/properties/lexical-handler", _
                         wrtFormatted
            .putProperty "http://xml.org/sax/properties/declaration-handler", _
                         wrtFormatted
            .parse txtOriginal.Text
        End With
        txtPrettied.Text = .output
    End With
End Sub

Private Sub Form_Load()
    ManageUI
End Sub