0

当社のソフトウェアは 50 台のクライアント PC にインストールされています。

ソフトウェアは、xml 構成ファイルから値を選択します。各クライアントは、構成ファイルに独自の個人ノード値 (true/false) を持っています。

現在、xml 構成ファイルにいくつかのノードを追加した新しいバージョンのソフトウェアをリリースしています。

ノードの値 (true/false) を保持しながら、クライアントの既存の構成ファイルに新しいノードを追加するにはどうすればよいですか。

ノートWe have to provide script to client to do this cannot do manually!

サンプル XML:

  <?xml version="1.0" encoding="utf-8"?>
<ApplicationSettings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <dbEngine>true</dbEngine> 
  <EnableAuditLogging>true</EnableAuditLogging> 
  <Schema>
    <FileNo>05</FileNo>
  </Schema> 
  <nodeToBeAdded1>
   <xml/>
   <xml/>
  </nodeToBeAdded1>
  <nodeToBeAdded2>
   <DefaultPath="c:\"/>
  </nodeToBeAdded2>
  <ExportTo>
    <ExportTo>
      <ID>0</ID>
       <Path>C:\</Path>
    </ExportTo>
  </ExportTo>
</ApplicationSettings>
4

2 に答える 2

2

これが、開始できる基本的なコードです。

Imports System.Xml

Public Class Form1
    Private Sub Test()
        Dim xDoc As XmlDocument
        Dim root As XmlNode
        Dim n As XmlNode

        xDoc = New XmlDocument()
        xDoc.Load("F:\tmp\a.xml")
        root = xDoc.SelectSingleNode("/ApplicationSettings")
        If xDoc.SelectSingleNode("/ApplicationSettings/NodeToBeAdded1") _
            Is Nothing Then
            n = root.InsertAfter(
                xDoc.CreateNode(XmlNodeType.Element, "NodeToBeAdded1", ""),
                xDoc.SelectSingleNode("/ApplicationSettings/Schema"))
            n.AppendChild(
                xDoc.CreateNode(XmlNodeType.Element, "XMLSubSomething", ""))
        End If
        xDoc.Save("F:\tmp\b.xml")
    End Sub
End Class
于 2013-08-16T11:06:50.480 に答える