0

I have this XML file:

<meps><mep><fullName>Carlos ZORRINHO</fullName><country>Portugal</country><politicalGroup>Group of the Progressive Alliance of Socialists and Democrats in the European Parliament</politicalGroup><id>124739</id><nationalPoliticalGroup>Partido Socialista</nationalPoliticalGroup></mep><mep><fullName>Željana ZOVKO</fullName><country>Croatia</country><politicalGroup>Group of the European People's Party (Christian Democrats)</politicalGroup><id>185341</id><nationalPoliticalGroup>Hrvatska demokratska zajednica</nationalPoliticalGroup></mep><mep><fullName>Marco ZULLO</fullName><country>Italy</country><politicalGroup>Non-attached Members</politicalGroup><id>125237</id><nationalPoliticalGroup>Movimento 5 Stelle</nationalPoliticalGroup></mep><mep><fullName>Milan ZVER</fullName><country>Slovenia</country><politicalGroup>Group of the European People's Party (Christian Democrats)</politicalGroup><id>96933</id><nationalPoliticalGroup>Slovenska demokratska stranka</nationalPoliticalGroup></mep></meps>

And I'd like to get a sed expression which finds the text inside all the "politicalgroup" tag. I've tried with:

sed -n 's:.*\(<politicalgroup">.*</politicalgroup>\).*:\1:p'

But didn't get any result. What am I doing wrong?

Thank you

js352
  • 364
  • 2
  • 9
  • 1
    Don't use sed for xml parsing. Use a tool like `xmllint` – anubhava Nov 10 '20 at 19:58
  • See in particular the entry in the linked duplicate describing how to use `xsltproc`, which has been available in mainstream Linux distributions for longer than the equivalent `xmllint` feature. Similarly, the description therein on how to create an XSLT template with `xmlstarlet` means you can use a tool you only need to install once, on your development system, to create a XSLT template you can deploy on any modern-ish system. – Charles Duffy Nov 10 '20 at 20:04

0 Answers0