我有我正在尝试编辑的任务调度程序xml文件。
<?xml version="1.0" encoding="UTF-16"?>
<Task xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task" version="1.4">
<RegistrationInfo>
<Date>2017-03-12T16:40:52.4111579</Date>
<Author>Kevin</Author>
<Description>Runs Batch File For Counter</Description>
<URI>THETASKTITLEGOESHERE</URI>
</RegistrationInfo>
<Actions Context="Author">
<Exec>
<Command>"ACTIONGOESHERE"</Command>
</Exec>
</Actions>
</Task>
这是我在批处理文件中的内容。
@echo off
pushd %~dp0
xml ed -inplace -r "/Task/RegistrationInfo/Author" -v CGL XMLTEST1.xml
xml ed -inplace -r "/Task/RegistrationInfo/URI" -v CGL-FakeTitle XMLTEST1.xml
xml ed -inplace -r "/Task/Actions/Exec/Command" -v "C:\Batch\Counter.bat" XMLTEST1.xml
pause
我在这里尝试过这些建议; xmlstarlet update value nothing happens
最后添加“> XMLTEST1output.xml”导致文件为空。任何的意见都将会有帮助。谢谢!
这适用于Linux和xmlstarlet:
xmlstarlet edit --inplace \
-N x="http://schemas.microsoft.com/windows/2004/02/mit/task" \
-u "//x:Task/x:RegistrationInfo/x:Author" -v "CGL" \
-u "//x:Task/x:RegistrationInfo/x:URI" -v "CGL-FakeTitle" \
-u "//x:Task/x:Actions/x:Exec/x:Command" -v "C:\Batch\Counter.bat" XMLTEST1.xml
我从-r
(重命名)切换到-u
更新值。在XMLTEST1.xml中,我用UTF-16
替换了UTF-8
。