1

I am trying to grep for a pattern in sipp xml file. That pattern might be commented in that file, it should skip the commented occurence and search for next occurence. Pattern : pcap file : test.xml As <exec play_pcap_audio="MULAW_p40_song.pcap"/> commented in xml file, it should return only <exec play_pcap_audio="MULAW_p41_song.pcap"/>

But I am getting

grep "pcap" test.xml
<exec play_pcap_audio="MULAW_p40_song.pcap"/>
<exec play_pcap_audio="MULAW_p41_song.pcap"/>

test.xml :

<!--
<nop>
  <action>
    <exec play_pcap_audio="MULAW_p40_song.pcap"/>
  </action>
</nop>
-->
<nop>
  <action>
    <exec play_pcap_audio="MULAW_p41_song.pcap"/>
  </action>
</nop>

Anyone can help me on this?

Sanchu
  • 35
  • 1
  • 5
  • Is grep a hard requirement, or can it be replaced with something else (i.e. a dedicated xml-parsing library)? Grep is based on regex patterns, and regex is Not A Good Tool for parsing xml. That's not to say what you want can't be done, but it [won't be pretty](https://stackoverflow.com/a/1732454/5166781). – Chris H Aug 28 '17 at 09:58
  • grep can be replaced..not mandatory to use grep – Sanchu Aug 28 '17 at 10:07
  • can you please help me on this – Sanchu Aug 28 '17 at 10:51
  • which tool can be used for parsing sipp xml file? – Sanchu Aug 29 '17 at 06:36
  • Chris H - can u help on this – Sanchu Aug 29 '17 at 14:44
  • Stack Overflow is not for product recommendations. You can find an xml reader yourself, I'm sure you've heard of google. – Chris H Aug 30 '17 at 06:41
  • Not asking for any product...just asking how to search for pattern in above case – Sanchu Aug 30 '17 at 09:48
  • I already told you, regular expressions are Bad At This. Any xml parsing tool will let you search a simple query like this. Find one and use it. – Chris H Aug 30 '17 at 11:21

0 Answers0