Popular Python recipes tagged "meta:requires=xml.etree.elementtree"http://code.activestate.com/recipes/langs/python/tags/meta:requires=xml.etree.elementtree/2011-01-19T16:05:24-08:00ActiveState Code RecipesFlatten XML to XPath syntax lines (Python)
2011-01-19T16:05:24-08:00Raphaël Jolivethttp://code.activestate.com/recipes/users/4135673/http://code.activestate.com/recipes/577547-flatten-xml-to-xpath-syntax-lines/
<p style="color: grey">
Python
recipe 577547
by <a href="/recipes/users/4135673/">Raphaël Jolivet</a>
(<a href="/recipes/tags/flatten/">flatten</a>, <a href="/recipes/tags/grep/">grep</a>, <a href="/recipes/tags/sed/">sed</a>, <a href="/recipes/tags/xml/">xml</a>, <a href="/recipes/tags/xpath/">xpath</a>).
</p>
<p>This script acts like <a href="http://www.ofb.net/~egnor/xml2/">xml2</a>.
It transforms a XML file into a flat text output, with <em>XPath</em>-like syntax, one line per XML node or attribute.
This format is more suitable for working with standard unix CLI utils (sed, grep, ... etc).</p>
An unofficial interface of Yahoo's Chinese segmentation. (Python)
2009-07-27T21:59:20-07:00Shao-chuan Wanghttp://code.activestate.com/recipes/users/4168519/http://code.activestate.com/recipes/576859-an-unofficial-interface-of-yahoos-chinese-segmenta/
<p style="color: grey">
Python
recipe 576859
by <a href="/recipes/users/4168519/">Shao-chuan Wang</a>
(<a href="/recipes/tags/chinese/">chinese</a>, <a href="/recipes/tags/segmentation/">segmentation</a>, <a href="/recipes/tags/yahoo/">yahoo</a>).
</p>
<p>An unofficial interface of Yahoo's Chinese segmentation.</p>
<ul>
<li>Before use it, you MUST specify your APPID in the code. * </li>
</ul>
<p>Yahoo's api documents: <a href="http://tw.developer.yahoo.com/cas/" rel="nofollow">http://tw.developer.yahoo.com/cas/</a></p>
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>
xml reverse-engineering ElementTree code generator (*whew*) (Python)
2007-06-13T16:08:19-07:00Andrew Moffathttp://code.activestate.com/recipes/users/2979564/http://code.activestate.com/recipes/521902-xml-reverse-engineering-elementtree-code-generator/
<p style="color: grey">
Python
recipe 521902
by <a href="/recipes/users/2979564/">Andrew Moffat</a>
(<a href="/recipes/tags/xml/">xml</a>).
Revision 2.
</p>
<p>takes an ambiguous xml file and generates the ET code to generate that xml file. this is useful if you have an example xml file, or an ambiguous xml file that you'd like to use as a template to parameterize certain elements. upgrades coming.</p>
ElementTree Text Helper (Python)
2006-11-29T22:20:13-08:00Raymond Hettingerhttp://code.activestate.com/recipes/users/178123/http://code.activestate.com/recipes/498286-elementtree-text-helper/
<p style="color: grey">
Python
recipe 498286
by <a href="/recipes/users/178123/">Raymond Hettinger</a>
(<a href="/recipes/tags/xml/">xml</a>).
Revision 4.
</p>
<p>Solves the "tail-problem" for prose-oriented XML. Recursively pulls text out of elements and their sub-elements. Extracts text from DocBook, XMHTL, and other nested XML markup.</p>
import ElementTree from everywhere (Python)
2006-07-14T01:19:09-07:00Trent Mickhttp://code.activestate.com/recipes/users/4173505/http://code.activestate.com/recipes/475126-import-elementtree-from-everywhere/
<p style="color: grey">
Python
recipe 475126
by <a href="/recipes/users/4173505/">Trent Mick</a>
(<a href="/recipes/tags/xml/">xml</a>).
Revision 4.
</p>
<p>effbot's ElementTree module (<a href="http://effbot.org/zone/element-index.htm" rel="nofollow">http://effbot.org/zone/element-index.htm</a>) is an excellent way to work with XML. It has a lot of incarnations though so distributing code that uses it right now is little bit of a pain. Here is a snippet you might want to use to import one of all the available incarnations -- hopefully the users of your script will have one.</p>