zipファイルの中にあるxmlの特定のタグの値を修正するPGMを作りたいです。
下記がサンプルになります。abc.zipにabc.xmlがあり、「test1です」を「テスト1です」に書き換えたいです。
どのような言語でどうコーディングするのが楽でしょうか
端末上で動作されるイメージなのでVBAかパワーシェルかVbscriptあたりで考えています。
vbaで調べてみると泥くさいことをしないといけない感じでした。(①zip解凍,②xml修正)
サンプルを提示して頂けますと助かります。
abc.zip
abc.xml
<test> <test1>test1です</test1> <test2>test2です</test2> </test>
-------------------------------①zip解凍--------------------------------
Public Sub UnZipFile(ByVal SrcPath As Variant, _
Optional ByVal DestFolderPath As Variant = "")
'ZIPファイルを解凍
'SrcPath:元ファイル
'DestFolderPath:出力先、指定しない場合は元ファイルと同じ場所
'※出力先に同名ファイルがあった場合はユーザー判断で処理
With CreateObject("Scripting.FileSystemObject")
If .FileExists(SrcPath) = False Then Exit Sub
If LCase(.GetExtensionName(SrcPath)) <> "zip" Then Exit Sub
If IsFolder(DestFolderPath) = False Then
DestFolderPath = .GetFile(SrcPath).ParentFolder.Path
End If
End With
With CreateObject("Shell.Application")
.NameSpace(DestFolderPath).CopyHere .NameSpace(SrcPath).Items
End With
End Sub
Private Function IsFolder(ByVal SrcPath As String) As Boolean
IsFolder = CreateObject("Scripting.FileSystemObject").FolderExists(SrcPath)
End Function
Private Function IsFile(ByVal SrcPath As String) As Boolean
IsFile = CreateObject("Scripting.FileSystemObject").FileExists(SrcPath)
End Function
Private Function AddPathSeparator(ByVal SrcPath As String) As String
If Right(SrcPath, 1) <> ChrW(92) Then SrcPath = SrcPath & ChrW(92)
AddPathSeparator = SrcPath
End Function
-------------------------------②xml修正--------------------------------
Sub loadXml()
Dim xD As New MSXML2.DOMDocument60
' ファイルから読み込み xD.Load "D:\test.xml" ' 値取得方法1 Debug.Print "Test Case 1" Debug.Print xD.DocumentElement.SelectSingleNode("test1").Text Debug.Print vbCrLf ↑修正のやり方がわかりません。。。。。。。。。。
End Sub
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。