本帖最后由 nmgwddj 于 2011-12-4 07:11 编辑
xml文件如下<DiskSet>
<Disk>
<DiskID>303</DiskID>
<FileSize>1024</FileSize>
<LockMemory>0</LockMemory>
<DiskState>4</DiskState>
<ManagerVersionID>0</ManagerVersionID>
<ManagerIP>0</ManagerIP>
<VTYear>2011</VTYear>
<VTMonth>12</VTMonth>
<VTDay>3</VTDay>
<VTHour>12</VTHour>
<VTMinute>25</VTMinute>
<VTSecond>36</VTSecond>
<VTMilliseconds>906</VTMilliseconds>
<DiskName>SYS</DiskName>
<DiskPath>E:\Image\SYS\T201112031225360890.img</DiskPath>
<VersionPath>E:\Image\SYS\T201112031225360890.xml</VersionPath>
</Disk>
<Disk>
<DiskID>304</DiskID>
<FileSize>1024</FileSize>
<LockMemory>0</LockMemory>
<DiskState>4</DiskState>
<ManagerVersionID>0</ManagerVersionID>
<ManagerIP>0</ManagerIP>
<VTYear>2011</VTYear>
<VTMonth>12</VTMonth>
<VTDay>3</VTDay>
<VTHour>18</VTHour>
<VTMinute>19</VTMinute>
<VTSecond>58</VTSecond>
<VTMilliseconds>875</VTMilliseconds>
<DiskName>Test</DiskName>
<DiskPath>E:\Image\Test\T201112031819580750.img</DiskPath>
<VersionPath>E:\Image\Test\T201112031819580750.xml</VersionPath>
</Disk>
</DiskSet>
代码如下,我运行了楞是报错,尝试了各种方式。。。$strSourceFile = 'DiskConfig.xml'
R_xml()
Func R_xml()
$objXML = ObjCreate("Microsoft.XMLDOM")
$sFile = $objXML.load($strSourceFile)
If Not $sFile Then
MsgBox(16, '', "加载" & $strSourceFile & "失败,文件不存在!!!")
Else
$objRootsite = $objXML.documentElement.selectSingleNode("DiskSet")
$AllNodesNum = $objRootsite.childNodes.length - 1
If $AllNodesNum < 0 Then
MsgBox(0, '', '没有找到文件')
Else
Local $temp
For $i = 0 To $AllNodesNum
$id = $i + 1
$DiskPath = $objRootsite.childNodes.item($i).childNodes.item(15).text
$temp &= $DiskPath & @CRLF
Next
MsgBox(0, '', $temp)
EndIf
EndIf
EndFunc ;==>R_xml
我只是想把每一个Disk下面的每个DiskPath的值读取出来。搞了一夜了 |