Popular Python recipes tagged "meta:requires=xml.sax.handler"http://code.activestate.com/recipes/langs/python/tags/meta:requires=xml.sax.handler/2011-01-11T00:28:15-08:00ActiveState Code RecipesQuiz Me 2.5 (testbank) (Python) 2011-01-11T00:28:15-08:00Stephen Chappellhttp://code.activestate.com/recipes/users/2608421/http://code.activestate.com/recipes/577531-quiz-me-25-testbank/ <p style="color: grey"> Python recipe 577531 by <a href="/recipes/users/2608421/">Stephen Chappell</a> (<a href="/recipes/tags/gui/">gui</a>, <a href="/recipes/tags/program/">program</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/quiz/">quiz</a>). </p> <p>Before discovering <a href="http://quizlet.com/" rel="nofollow">http://quizlet.com/</a>, the following program was developed for running custom quizzes to help with studying for college courses. The program is not very advanced, but it works reasonably well for what it was designed to do. If the program were developed further, it would need greater capabilities than it currently has and would require a secondary system for actually creating the quizzes (currently, they are hand-typed). Quiz Me could be a starting point for anyone who wishes to actually write a program such as this and inspire others to write much better programs than what this recipe currently offers.</p> <p>Quizes are stored as XML files and must be parsed and processed for use within the Quiz Me application. BankParser acts as a ContentHandler when used in parsing one of these XML files. It builds a tree of _Nodes, extracts attributes and textual data as needed, and validates the structure of the quiz bank data stream. _Nodes act as an abstract representation of XML elements and have the capability of reconstructing the relevant part of the XML that they encapsulate. Several classes follow that inherit from the _Node class and specify an attribute that node is expected to contain. The parse function takes a filename and returns a TestBank root object if parsing and validation were successful at this stage of a quiz's loading sequence.</p> XML to Python data structure (Python) 2009-05-31T16:10:38-07:00Wai Yip Tunghttp://code.activestate.com/recipes/users/2382677/http://code.activestate.com/recipes/534109-xml-to-python-data-structure/ <p style="color: grey"> Python recipe 534109 by <a href="/recipes/users/2382677/">Wai Yip Tung</a> (<a href="/recipes/tags/xml/">xml</a>). Revision 8. </p> <p>This simple method construct Python data structure from XML in one simple step. Data is accessed using the Pythonic "object.attribute" notation. See the discussion below for usage examples.</p> Simpliest XML generator (Python) 2006-09-22T21:02:11-07:00Trionice mail.roma1 at gmail.comhttp://code.activestate.com/recipes/users/3005523/http://code.activestate.com/recipes/498101-simpliest-xml-generator/ <p style="color: grey"> Python recipe 498101 by <a href="/recipes/users/3005523/">Trionice mail.roma1 at gmail.com</a> (<a href="/recipes/tags/xml/">xml</a>). Revision 4. </p> <p>This is merely a sketch for a bare-bones XML 1.0 generator.I wrote it for working on little tasks for which other generators seem to be too much complex. Python version used to test this code was 2.4.3 on a Win32 platform.</p> Simple XML serlializer/de-serializer using Python dictionaries and marshalling (Python) 2005-06-07T09:13:40-07:00Anandhttp://code.activestate.com/recipes/users/760763/http://code.activestate.com/recipes/415983-simple-xml-serlializerde-serializer-using-python-d/ <p style="color: grey"> Python recipe 415983 by <a href="/recipes/users/760763/">Anand</a> (<a href="/recipes/tags/xml/">xml</a>). Revision 2. </p> <p>This recipe presents a way of serializing &amp; de-serializing XML using the marshal module. The XML is converted to an equivalent Python dictionary first, which is marshaled to serialize it. De-serialization first unmarshals the dictionary from the file, and constructs the original XML.</p> Check xml well-formedness (Python) 2001-06-14T19:41:15-07:00Paul Prescodhttp://code.activestate.com/recipes/users/11203/http://code.activestate.com/recipes/52256-check-xml-well-formedness/ <p style="color: grey"> Python recipe 52256 by <a href="/recipes/users/11203/">Paul Prescod</a> (<a href="/recipes/tags/xml/">xml</a>). Revision 2. </p> <p>This small script will check whether one or more XML documents are well-formed.</p> Extract text from XML document (Python) 2001-06-14T19:42:23-07:00Paul Prescodhttp://code.activestate.com/recipes/users/11203/http://code.activestate.com/recipes/65128-extract-text-from-xml-document/ <p style="color: grey"> Python recipe 65128 by <a href="/recipes/users/11203/">Paul Prescod</a> (<a href="/recipes/tags/xml/">xml</a>). Revision 2. </p> <p>People often ask how to extract the text from an XML document. This small program does it.</p> Count tags in a document (Python) 2001-06-13T02:30:27-07:00Paul Prescodhttp://code.activestate.com/recipes/users/11203/http://code.activestate.com/recipes/65127-count-tags-in-a-document/ <p style="color: grey"> Python recipe 65127 by <a href="/recipes/users/11203/">Paul Prescod</a> (<a href="/recipes/tags/xml/">xml</a>). Revision 3. </p> <p>This is an example SAX application and can be used as the basis for any SAX application. It is somewhat useful in and of itself when you want to get a sense of the frequency of occurance of particular elements in XML.</p>