Comment #1 posted on 2021-08-05 14:54:19 by norrist
My one cool xmlstarlet trick
I had to install an xml config file on a bunch of servers.
The xml was the same for every server except the hostname had to be added to a specific field.
My first thought was to use sed, but anyone who has tried parsing xml with regex knows just how far I got.
Searching for something like sed that understood xml tags led me to xmlstarlet.
Here is the command I used to add the hostname of the server to the xml path "info/host-id":
xmlstarlet ed --inplace -u info/host-id -v `hostname -f` /path/to/info.xml
Comment #2 posted on 2021-12-22 18:54:26 by dnt
I consulted this episode this week
When I listened to "We need to talk about XML", I nodded in agreement. Working in localization there's a lot of XLIFF, so I have learned to appreciate it. This week I had a chance to use xmlstarlet at work, so I came back and had another listen to this. There was some trouble figuring out the deal with XML namespaces, I found that in xmlstarlet you can use //_:node where the underscore stands for the default namespace. For now, this just worked, but I do need to learn more about namespaces. Thanks again!
Note to Verbose Commenters
If you can't fit everything you want to say in the comment below then you really should record a response show instead.
Note to Spammers
All comments are moderated. All links are checked by humans. We strip out all html. Feel free to record a show about yourself, or your industry, or any other topic we may find interesting. We also check shows for spam :).