Given an XML with some blocks ending within the same tag and others with a separate tag:
<parent name="parent_1" team="team_a"> <child name="child_1" team="team_b"/> </parent> <parent name="parent_2" team="team_c"/> <parent name="parent_3" team="team_b"/>
How can extract the block for a given name?
I have:
awk "/<parent name=\"$name\"/,/<\/parent>/" $file
which would work for $name=parent_1, and:
awk "/<parent name=\"$name\"/,/\/>/" $file
which would work for parent_2 or parent_3 but not sure how to do both.
I tried:
awk "/<parent name=\"$name\"/,/[\/>|<\/parent>]/" $file
as an OR condition but for parent_1 it still gives me:
<parent name="parent_1" team="team_a">
Can that be done?