augeas: update xml value based on previous tag

asked 2017-06-09 09:38:07 -0500

rajeevsharma gravatar image

Hi, I have a simple issue while updating xml file but I'm not able to find the solution after trying many things out. I am trying to update password based on the username which is defined in just previous tag of password tag. My xml file is below:

<ns2:tokens xmlns:ns2="">


Here, based on the username in <name> tag I need to update password in <value> tag. I have tried following but it's not working:

augeas {'Update external.xml':
  incl    => '/tmp/external.xml',
  context => '/files/tmp/external.xml/ns2:tokens',
  lens    => "xml.lns",
  changes => ["set /files/external.xml/token/[name/#text='user2'/name]/value/#text newpass2",]

Any idea?

edit retag flag offensive close merge delete