Python xml.etree.cElementTree() Examples
The following are 2
code examples of xml.etree.cElementTree().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
xml.etree
, or try the search function
.
Example #1
Source File: test_treewalkers.py From MARA_Framework with GNU Lesser General Public License v3.0 | 5 votes |
def set_attribute_on_first_child(docfrag, name, value, treeName): """naively sets an attribute on the first child of the document fragment passed in""" setter = {'ElementTree': lambda d: d[0].set, 'DOM': lambda d: d.firstChild.setAttribute} setter['cElementTree'] = setter['ElementTree'] try: setter.get(treeName, setter['DOM'])(docfrag)(name, value) except AttributeError: setter['ElementTree'](docfrag)(name, value)
Example #2
Source File: client.py From BhagavadGita with GNU General Public License v3.0 | 5 votes |
def get_etree(): global _etree if _etree is not None: return _etree try: from lxml import etree as _etree except ImportError: try: from xml.etree import cElementTree as _etree except ImportError: try: from xml.etree import ElementTree as _etree except ImportError: raise TypeError('lxml or etree not found') return _etree