我正在尝试使用以下代码创建XML文件。
Set Client = xmlDoc.CreateElement("Client")
Set Client_ID = xmlDoc.CreateElement("Client_ID")
Client_ID.AppendChild kunden
Set name = xmlDoc.CreateElement("GivenName")
Client_ID.SelectNodes("//@Client//Client_ID")
Set surnamename = xmlDoc.CreateElement("surname")
Client_ID.AppendChild name
Client_ID.AppendChild surname
这就是我得到的:
<ROOT>
<Info>
<Number>atl-ws-001</Number>
<Date>04.12.2017</Date>
</Info>
<Test>
<Client>
<Client_ID/>
<GiveName/>
<SURNAME/>
</Client>
</Test>
</ROOT>
并且我正在尝试获取像这样的XML文件:
<ROOT>
<Info>
<Number>atl-ws-001</Number>
<Date>04.12.2017</Date>
</Info>
<Test>
<Client>
<Client_ID>
<GivenName/>
<surname/>
</Client_ID>
</Client>
</Test>
</ROOT>
答案 0 :(得分:0)
只需使用本书的方法即可。演示:
Option Explicit
Dim o : Set o = CreateObject("msxml2.domdocument")
o.loadXml "<a><b></b></a>"
Dim Client : Set Client = o.createElement("Client")
Dim Client_ID : Set Client_ID = o.createElement("Client_ID")
Client_ID.appendChild o.createElement("GivenName")
Client_ID.appendChild o.createElement("SurName")
Client.appendChild Client_ID
o.SelectSingleNode("/a/b").appendChild Client
WScript.Echo o.xml
输出:
cscript 47637542.vbs
<a><b><Client><Client_ID><GivenName/><SurName/></Client_ID></Client></b></a>
(使用XPATH&#34; //&#34;几乎总是一个坏主意)