i have below string i.e., produced by my other Ansible-playbook URI module, which looks like XML but not actually. It is single line string starting from XML header to tail.
echo $log
<?xml version='1.0' encoding='UTF-8'?>\n<response>\n <data>\n <configElement>\n <elementType>access-control</elementType>\n <attribute>\n <name>realm-id</name>\n <value>Core</value>\n </attribute>\n <attribute>\n <name>realm-id</name>\n <value>REC12-CL1</value>\n </attribute>\n <attribute>\n <name>realm-id</name>\n <value>REC12-ML1</value>\n </attribute>\n <attribute>\n <name>last-modified-date</name>\n <value>2017-11-28 16:47:31</value>\n </attribute>\n </configElement>\n </data>\n <messages/>\n <links/>\n</response>\n
how can i fetch <realm-id>
and its very next value <value>
from above string.
i have already tried greo -o
& some sed
cut
methods, but no luck.
please help.
expected output is something like
realm-id,Core
realm-id,REC12-CL1
realm-id,REC12-ML1