O'Reilly logo

XML Processing with Python by Sean McGrath

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

9.14. Bringing It All Together

We end this chapter with a complete copy of the finished xgrep.

 CD-ROM reference=9043.txt import string,os,sys import re from pyxie import * # Use "bits" to store boolean options MARK_HITS = 1 USE_EVENT_STYLE = 1 << 1 USE_TREE_STYLE = 1 << 2 VALIDATE = 1 << 3 MATCH_ATTRIBUTE_NAME = 1 << 4 MATCH_ATTRIBUTE_VALUE = 1 << 5 MATCH_PROCESSING_INSTRUCTION = 1 << 6 MATCH_ELEMENT_TYPE_NAME = 1 << 7 MATCH_CHARACTER_DATA = 1 << 8 PARENT_CONTEXT = 1 << 9 ANCESTOR_CONTEXT = 1 << 10 CHILD_CONTEXT = 1 << 11 DESCENDANT_CONTEXT = 1 << 12 SIBLING_CONTEXT = 1 << 13 # PrintMatch subroutine called from many places in the code # prints the match details. def PrintMatch(filename,description,line,mo,StartOfHit, EndOfHit,out): out.write ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required