Skip to content

Adding xml element with attribute to logback.xml #1125

Answered by mikefarah
MarcoHuigen asked this question in Q&A
Discussion options

You must be logged in to vote

Hi - sorry for the late response.

So when yq parses this xml, 'appender-ref' is an array (as it appears multiple times). All you need to do is add another item to that array.

If it helps (it did for me) first keep the output as yaml (omit the -o=xml) to get an understanding of what happening under the hood.

Regardless:

yq '.configuration.root.appender-ref += {"+ref": "YETANOTHERLOG"}' sample.xml -p=xml  -o=xml

Replies: 3 comments 7 replies

Comment options

You must be logged in to vote
2 replies
@MarcoHuigen
Comment options

@mikefarah
Comment options

Answer selected by MarcoHuigen
Comment options

You must be logged in to vote
3 replies
@mikefarah
Comment options

@mikefarah
Comment options

@austinarbor
Comment options

Comment options

You must be logged in to vote
2 replies
@code-sergeant
Comment options

@mikefarah
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants