2011-10-07 57 views
0

我試圖用xmlstarlet插入一個新元素,但是當我運行該命令時,它只是列出了我試圖插入到的xml文件。任何建議都會很棒。xmlstarlet編輯插入語法

xml ed -s /chkSys/machine/registry -t elem -n key -v "" -i /registry/key -t attr -n value -v "'C:\Program Files\Microsoft SQL Server'" -v path "HKLM\software\symantec\Symantec Endpoint Protection\AV\Exclusions\ScanningEngines" --net \\server3\e$\temp\chksys\chksys.xml 

##Old## 
<?xml version="1.0" encoding="utf-8"?> 
<chksys> 
    <machine> 
     <registry> 

     </registry> 
    </machine> 
</chksys> 

##New## 
<?xml version="1.0" encoding="utf-8"?> 
<chksys> 
    <machine> 
     <registry> 
      <key value="'C:\Program Files\Microsoft SQL Server'" path "HKLM\software\symantec\Symantec Endpoint Protection\AV\Exclusions\ScanningEngines\Directory\Admin\1075182566\DirectoryName"/> 
     </registry> 
    </machine> 
</chksys> 

回答

2

你的命令是有點過,當你插入你應該使用完整路徑鍵:

xml ed --net^
    -s /chksys/machine/registry -t elem -n key -v ""^
    -i /chksys/machine/registry/key -t attr -n value^
     -v "'C:\Program Files\Microsoft SQL Server'"^
    -i /chksys/machine/registry/key -t attr -n path^
     -v "HKLM\software\symantec\Symantec Endpoint Protection\AV\Exclusions\ScanningEngines"^
    OLDFILE > NEWFILE 

,將放在編輯的XML在NEWFILE,如果你想直接更改的oldfile你可以使用--inplace或-L選項。

xml ed --net --inplace^
    ...