Ask Your Question

using Augeas to modify named parameter in xml

asked 2015-12-08 12:26:17 -0600

mlanghor gravatar image

I've not used Augeas previously, I've gotten it to modify a parameter based on position, but there exists the possibility of the source file changing.

For this example snippet:

    <xProperty xName="application.navigation.pane.enabled">false</xProperty>
    <xProperty xName="application.hideTopLevelMenu">false</xProperty>
    <xProperty xName="grid.magnify.enable">false</xProperty>
    <xProperty xName="application.environmentInfo">TEST</xProperty>
    <xProperty xName="application.debugEnabled">true</xProperty>

I have a need to replace the #text contained in the tag for "application.environmentInfo", but this file has 50+ xProperties and I can't guarantee that it's always #4 in this example.

How can I target the "application.environmentInfo" tag specifically?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2015-12-08 13:45:11 -0600

mlanghor gravatar image

Figured this one out, I wasn't properly specifying the xName.

augeas {"AppConfig-aug":
  lens    => 'Xml.lns',
  incl    => '/tmp/AppConfig.xml',
  changes => [
    'set /files/tmp/AppConfig.xml/xProperties/xProperty[#attribute/xName="application.environmentInfo"]/#text  DEV'],
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2015-12-08 12:26:17 -0600

Seen: 179 times

Last updated: Dec 08 '15