0
votes

I'm trying to insert a new element with xmlstarlet but when I run the command it just list the xml file I'm trying to insert to. Any suggestions would be great.

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>
1

1 Answers

2
votes

Your command is a bit off, you should use the full path to key when you insert:

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

That will put the edited xml in NEWFILE, if you want to change OLDFILE directly you can use the --inplace or -L option.

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