As said before, don't use regexp, use a module.
But much to the surprise of everyone here, I am not going to pimp XML::Twig this time! xml_grep2, packaged as App::xml_grep2, will do this quite simply from the command line:
xml_grep2 -v '//start_element[.//user_id]' user.xml > elements_with_no +_user_id.xml xml_grep2 -v '//start_element[count(.//user_id)=0]' user.xml > element +s_with_user_id.xml
xml_grep2 works like grep, except it uses XPath instead of regular expression. So the -v flag will filter out any element that matches the XPath expression. The first one matches elements with a user_id descendant, and the second one matches elements with none.
Voilą!
In reply to Re: Need to process a XML file through Perl
by mirod
in thread Need to process a XML file through Perl
by paragkalra
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |