我正在尝试在VBScript中编写以下代码。我有一个目录,其中包含以下面第一种格式显示的多个XML文件。文件中只有一个<ID>
条目。我正在尝试将文件合并为下面的第二种格式。任何帮助都会有用。
<?xml version="1.0" encoding="utf-8"?>
<ID>
<YID></YID>
<ScanUser></ScanUser>
<pagecount></pagecount>
</ID>
<data> <id> <YID></YID> <ScanUser></ScanUser> <pagecount></pagecount> </id>
<id> <YID></YID> <ScanUser></ScanUser> <pagecount></pagecount> </id>
<id> <YID></YID> <ScanUser></ScanUser> <pagecount></pagecount> </id></data>
这是我到目前为止所拥有的:
'Create new XML to store combined files.
Set docAll = CreateObject("MSXML2.DOMDocument.3.0")
'For testing purposed I am trying to combine two XML files.
Set doc1 = CreateObject("MSXML2.DOMDocument.3.0")
Set doc2 = CreateObject("MSXML2.DOMDocument.3.0")
doc1.Load "e:\1.xml"
doc2.Load "e:\2.xml"
'Add new root element <data>
Set objRoot = xmlDoc.CreateElement("data")
docAll.AppendChild objRoot
'Iterate through XML files and import into new XML.
'This is where I am stuck. Assuming steps 1 and 2 are correct.
'Save `docAll`
docAll.Save "e:\reqs\saved.xml"