hyl821 发表于 2012-8-31 15:23:43

XML 怎么批量修改!

<NMenu Version="1.0">
<Computer Name="002" MAC="8C:89:A5:CD:76:91" Flag="0008" IP="192.168.1.190" Netmask="255.255.255.0" Gateway="192.168.1.254" BootFile="boot.bin"/>
<Computer Name="003" MAC="8C:89:A5:CD:76:4D" Flag="0008" IP="192.168.1.191" Netmask="255.255.255.0" Gateway="192.168.1.254" BootFile="boot.bin"/>
</NMenu>

我想把计算机名,改成对应你的IP 地址。不知道怎么改

hyl821 发表于 2012-8-31 15:41:57

有人会吗
----------------

shqf 发表于 2012-8-31 19:40:58

#include <_XMLDomWrapper.au3>
Local $oXMLDoc = _XMLFileOpen(@ScriptDir & "\1.xml")
$NCount=_XMLGetNodeCount("NMenu/Computer")
For $i=1 To $NCount
        $GAttrib = _XMLGetAttrib("/NMenu/Computer"&"["&$i&"]","IP" );获取属性IP的值
        _XMLSetAttrib("NMenu/Computer"&"["&$i&"]", "Name", $GAttrib);设置属性Name新的值       
Next

#cs 以下为1.xml的内容
<?xml version="1.0" encoding="utf-8"?>
<NMenu Version="1.0">
<Computer Name="002" MAC="8C:89:A5:CD:76:91" Flag="0008" IP="192.168.1.190" Netmask="255.255.255.0" Gateway="192.168.1.254" BootFile="boot.bin"/>
<Computer Name="003" MAC="8C:89:A5:CD:76:4D" Flag="0008" IP="192.168.1.191" Netmask="255.255.255.0" Gateway="192.168.1.254" BootFile="boot.bin"/>
</NMenu>
#ce
页: [1]
查看完整版本: XML 怎么批量修改!