Popular recipes tagged "elementtree" but not "writing"http://code.activestate.com/recipes/tags/elementtree-writing/2013-06-16T19:14:58-07:00ActiveState Code RecipesXML to PDF book with ElementTree and xtopdf (Python) 2013-06-16T19:14:58-07:00Vasudev Ramhttp://code.activestate.com/recipes/users/4173351/http://code.activestate.com/recipes/578561-xml-to-pdf-book-with-elementtree-and-xtopdf/ <p style="color: grey"> Python recipe 578561 by <a href="/recipes/users/4173351/">Vasudev Ram</a> (<a href="/recipes/tags/ebooks/">ebooks</a>, <a href="/recipes/tags/elementtree/">elementtree</a>, <a href="/recipes/tags/pdf/">pdf</a>, <a href="/recipes/tags/publishing/">publishing</a>, <a href="/recipes/tags/xml/">xml</a>, <a href="/recipes/tags/xtopdf/">xtopdf</a>). </p> <p>This recipe shows how to create a PDF book from XML text content. It requires my xtopdf toolkit, the ElementTree module (from Python's standard library) and the open source version of the ReportLab toolkit.</p> <p>Create an XML template file like this:</p> <p>&lt;?xml version="1.0"?&gt; &lt;book&gt; &lt;chapter&gt; Chapter 1 content here. &lt;/chapter&gt;</p> <pre class="prettyprint"><code> &lt;chapter&gt; Chapter 2 content here. &lt;/chapter&gt; </code></pre> <p>&lt;/book&gt;</p> <p>Then populate the chapter elements with the text of each of the chapters of your book, as text. Call that file, your_book.xml, say.</p> <p>Then run:</p> <p>python XMLtoPDFBook.py your_book.xml your_book.pdf</p> <p>Now the contents of your book will be in your_book.pdf</p> <p>More details and the full code here:</p> <p><a href="http://jugad2.blogspot.in/2013/06/create-pdf-books-with-xmltopdfbook.html" rel="nofollow">http://jugad2.blogspot.in/2013/06/create-pdf-books-with-xmltopdfbook.html</a></p> <ul> <li>Vasudev Ram <a href="http://dancingbison.com" rel="nofollow">dancingbison.com</a></li> </ul> ElementTree CDATA support (Python) 2008-10-10T12:29:33-07:00Eli Golovinskyhttp://code.activestate.com/recipes/users/2770692/http://code.activestate.com/recipes/576536-elementtree-cdata-support/ <p style="color: grey"> Python recipe 576536 by <a href="/recipes/users/2770692/">Eli Golovinsky</a> (<a href="/recipes/tags/elementtree/">elementtree</a>, <a href="/recipes/tags/xml/">xml</a>). Revision 2. </p> <p>This recipe monkey-patches the ElementTree library to allow correct parsing and generation of CDATA sections.</p>