xmlstarlet update value nothing happens

前端 未结 1 1244
攒了一身酷
攒了一身酷 2021-01-19 06:26

I have an xml file



    
    
            localhost         


        
相关标签:
1条回答
  • 2021-01-19 07:06

    You have two faults:

    1. Your XPath expression is invalid. Drop the trailing slash so it becomes /preferences/options/dbUser
    2. By default xmlstarlet does not change the input file, instead it outputs the result in stdout. You can either replace the original file with the xmlstarlet output by redirecting the output to your input file (or to any other file) xmlstarlet edit --update '/preferences/options/dbUser' --value 123 preferences.xml > preferences.xml or you can use global option --inplace which replaces the input file with the output (instead of printing it to stdin). The command is xmlstarlet edit --inplace --update '/preferences/options/dbUser' --value 123 preferences.xml

    Type xmlstarlet edit --help for more info

    0 讨论(0)
提交回复
热议问题