16.3. xTract Version 1 Source Code

Here is the source code for version 1 of xTract.

 CD-ROM reference=16007.txt """ xTract -- First Steps Toward an XML-Based Query-by-Example System for Web Resource Retrieval Given: A URL referencing an XML file An XML fragment to treat as a Query By Example template (containing Python regular expressions) Return list of matching XML fragments. XML Processing with Python Sean Mc Grath """ from geturl import geturl from pyxie import * import re,sys # Set this to 1 to get a trace view of what is # happening. debug = 1 def xTract(ResourceXML,QueryByExampleXML): """ Search an XML file, using another XML file as a query template. Return a list of matching XML fragments. """ # Initialize result. ResultFragments = [] ...

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.