Change XML attribute

Apache 2.0

Alters XML attribute value on a specified element.

org.openrewrite.xml.ChangeTagAttribute

Required

The name of the element whose attribute's value is to be changed. Interpreted as an XPath expression.

The name of the attribute whose value is to be changed.

The new value to be used for key specified by attributeName, Set to null if you want to remove the attribute.

Optional

Only change the property value if it matches the configured oldValue.

regexBoolean

Default false. If true, oldValue will be interpreted as a Regular Expression, and capture group contents will be available in newValue.

mod run . --recipe=org.openrewrite.xml.ChangeTagAttribute \ -P elementName=property \ -P attributeName=name \ -P newValue=newfoo.bar.attribute.value.string

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.