May 8, 2016, 1:44 AM
Post #2 of 4
The short answer is no. In general, you should not try to edit XLM files (or HTML files) with regexes. You should use a parser and there are many modules to do that on the CPAN (see for example http://search.cpan.org/dist/XML-LibXML/LibXML.pod or http://search.cpan.org/~msergeant/XML-Parser-2.36/Parser.pm).
Re: [cognizant] Regex for xml tags deletion
[In reply to]
Now, of course, for very simple (and well formatted) cases such as your example, it might be possible to do it (though not recommended, as simple cases usually become more complicated with time). You gave an example, but did not specify the implicit rule you want to use: just discard lines with the <son> and <daughter> tags? Something else? I can't really give a solution if you don't state more clearly how (in English, not in Perl) you want to do it.