Minidom extension
Project description
Minidom Extension
Short presentation
Functions to improve xml.dom.minidom [1] tools in Python.
class DOMCompanion :
- def init(self, doc = None) : to build a DOM DocumentCompanion
- def parse(self, file, validate = False): to load an XML file
- def getElementsByTagName(self, name) : DOM getElementsByTagName
- def getElementById(self, id) : to retrieve an element by its ID
- def getAttributsByIdref(self, id) : to retrieve attributs that refers to an ID
- def toLighter(self, del_spaces = True, del_comments = True, del_pi = True) : to suppress text nodes (with only separators), processing instructions and/or comments
- def validate(self) : to validate the XML according its DTD (enrich it too)
Exemple
cine = DOMCompanion()
cine.parse("semaine10.xml", True)
print(cine.doc.toxml())
print(cine.getElementById('Ka'))
print(cine.toLighter().toxml())
How to install ?
pip install minidom-ext
Links
[1] Python 'minidom' : https://docs.python.org/3/library/xml.dom.minidom.html
[2] DOM using Python : https://docs.python.org/3/library/xml.dom.html
(c) E. Desmontils, University of Nantes, november 2020
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
minidom_ext-0.0.3.tar.gz
(11.2 kB
view hashes)
Built Distribution
Close
Hashes for minidom_ext-0.0.3-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ae346516c7a8256d54081917e9dab932c3e6b935b50df59256119977c0eedff9 |
|
MD5 | 5277d21cf371a61b609f0723d0509815 |
|
BLAKE2b-256 | b915d67f1a4afe73dc0d39577e5273511b175d91fb39453f7b72715bc3c67376 |