File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # -*- coding: utf-8 -*-
2+ #
3+ # oxml.py
4+ #
5+ # Copyright (C) 2012, 2013 Steve Canny scanny@cisco.com
6+ #
7+ # This module is part of python-opc and is released under the MIT License:
8+ # http://www.opensource.org/licenses/mit-license.php
9+
10+ """
11+ Classes that directly manipulate Open XML and provide direct object-oriented
12+ access to the XML elements.
13+ """
14+
15+ from lxml import etree , objectify
16+
17+
18+ # configure objectified XML parser
19+ fallback_lookup = objectify .ObjectifyElementClassLookup ()
20+ element_class_lookup = etree .ElementNamespaceClassLookup (fallback_lookup )
21+ oxml_parser = etree .XMLParser (remove_blank_text = True )
22+ oxml_parser .set_element_class_lookup (element_class_lookup )
23+
24+
25+ # ===========================================================================
26+ # functions
27+ # ===========================================================================
28+
29+ def oxml_fromstring (text ):
30+ """``etree.fromstring()`` replacement that uses oxml parser"""
31+ return objectify .fromstring (text , oxml_parser )
You can’t perform that action at this time.
0 commit comments