8.7. The Match Printing Function

With the addition of all the command-line options, there are now a total of six points in the code where a match needs to be printed out. Five of these occur in the XML-aware XMLGrepEvents and one occurs in the non-XML-aware XMLGrep function. Rather than duplicate the printing code six times, we introduced a subroutine. A side effect is having a single place to make code changes if we want to modify the way xgrep generates its output.

Get XML Processing with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.