https://github.com/danr/xmldestroyer
Bottom-up transformation of XML into python generators, XML, JSON or text.
https://github.com/danr/xmldestroyer
Last synced: 25 days ago
JSON representation
Bottom-up transformation of XML into python generators, XML, JSON or text.
- Host: GitHub
- URL: https://github.com/danr/xmldestroyer
- Owner: danr
- License: mit
- Created: 2016-12-16T15:52:27.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-12-20T16:25:55.000Z (over 9 years ago)
- Last Synced: 2025-11-28T23:59:24.186Z (8 months ago)
- Language: Python
- Size: 158 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
xmldestroyer
============
This library does a bottom-up transformation of XML documents, extracting the
parts that are relevant for the task at hand, and either returning it as a
python generator, or serializing it to disk as XML (again!), JSON or text.
One design goal is to be able to process gigabyte-sized documents with constant
memory footprint.
Inspired by the Haskell libraries
`Scrap Your Boilerplate `__,
`uniplate `__ and
`geniplate `__.
Example, get the texts from all ``
`` tags in a document:
::
from xmldestroyer import xd
import sys
def p(text, _attrs, _children, _parents):
return text
infile, outfile = sys.args
xd(infile, outfile, p=p)
This outputs a text file with the text from all ``
`` tags, one per line.
Works with python 2.7, 3.3, 3.4 and 3.5.