{ "info": { "author": "James Murty", "author_email": "james@murty.co", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: ISC License (ISCL)", "Natural Language :: English", "Programming Language :: Python", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Topic :: Text Processing :: Markup :: XML" ], "description": "===============================\nxml4h: XML for Humans in Python\n===============================\n\n*xml4h* is an ISC licensed library for Python to make working with XML\na human-friendly activity.\n\nThis library exists because Python is awesome, XML is everywhere, and combining\nthe two should be a pleasure. With *xml4h*, it can be.\n\n\nFeatures\n--------\n\n*xml4h* is a simplification layer over existing Python XML processing libraries\nsuch as *lxml*, *ElementTree* and the *minidom*. It provides:\n\n- a rich pythonic API to traverse and manipulate the XML DOM.\n- a document builder to simply and safely construct complex documents with\n minimal code.\n- a writer that serialises XML documents with the structure and format that you\n expect, unlike the machine- but not human-friendly output you tend to get\n from other libraries.\n\nThe *xml4h* abstraction layer also offers some other benefits, beyond a nice\nAPI and tool set:\n\n- A common interface to different underlying XML libraries, so code written\n against *xml4h* need not be rewritten if you switch implementations.\n- You can easily move between *xml4h* and the underlying implementation: parse\n your document using the fastest implementation, manipulate the DOM with\n human-friendly code using *xml4h*, then get back to the underlying\n implementation if you need to.\n\n\nInstallation\n------------\n\nInstall *xml4h* with pip::\n\n $ pip install xml4h\n\nOr install the tarball manually with::\n\n $ python setup.py install\n\n\nLinks\n-----\n\n- GitHub for source code and issues: http://github.com/jmurty/xml4h\n- ReadTheDocs for documentation: http://xml4h.readthedocs.org\n- Install from the Python Package Index: http://pypi.python.org/pypi/xml4h\n\n\nIntroduction\n------------\n\nHere is an example of parsing and reading data from an XML document using\n\"magical\" element and attribute lookups::\n\n >>> import xml4h\n >>> doc = xml4h.parse('tests/data/monty_python_films.xml')\n\n >>> for film in doc.MontyPythonFilms.Film[:3]:\n ... print film['year'], ':', film.Title.text\n 1971 : And Now for Something Completely Different\n 1974 : Monty Python and the Holy Grail\n 1979 : Monty Python's Life of Brian\n\nYou can also use a more traditional approach to traverse the DOM::\n\n >>> for film in doc.child('MontyPythonFilms').children('Film')[:3]:\n ... print film.attributes['year'], ':', film.children.first.text\n 1971 : And Now for Something Completely Different\n 1974 : Monty Python and the Holy Grail\n 1979 : Monty Python's Life of Brian\n\nThe *xml4h* builder makes programmatic document creation simple, with\na method-chaining feature that allows for expressive but sparse code that\nmirrors the document itself::\n\n >>> b = (xml4h.build('MontyPythonFilms')\n ... .attributes({'source': 'http://en.wikipedia.org/wiki/Monty_Python'})\n ... .element('Film')\n ... .attributes({'year': 1971})\n ... .element('Title')\n ... .text('And Now for Something Completely Different')\n ... .up()\n ... .elem('Description').t(\n ... \"A collection of sketches from the first and second TV\"\n ... \" series of Monty Python's Flying Circus purposely\"\n ... \" re-enacted and shot for film.\").up()\n ... .up()\n ... )\n\n >>> # A builder object can be re-used\n >>> b = (b.e('Film')\n ... .attrs(year=1974)\n ... .e('Title').t('Monty Python and the Holy Grail').up()\n ... .e('Description').t(\n ... \"King Arthur and his knights embark on a low-budget search\"\n ... \" for the Holy Grail, encountering humorous obstacles along\"\n ... \" the way. Some of these turned into standalone sketches.\"\n ... ).up()\n ... .up()\n ... )\n\nPretty-print your XML document with the flexible write() and xml() methods::\n\n >>> b.write_doc(indent=4, newline=True) # doctest: +ELLIPSIS\n \n \n \n And Now for Something Completely Different\n A collection of sketches from ...\n \n \n Monty Python and the Holy Grail\n King Arthur and his knights embark ...\n \n \n\n\nWhy?\n----\n\nPython has three popular libraries for working with XML, none of which are\nparticularly easy to use:\n\n- `xml.dom.minidom `_\n is a light-weight, moderately-featured implementation of the W3C DOM\n that is included in the standard library. Unfortunately the W3C DOM API is\n terrible \u2013 the very opposite of pythonic \u2013 and the *minidom* does not\n support XPath expressions.\n- `xml.etree.ElementTree `_\n is a fast hierarchical data container that is included in the standard\n library and can be used to represent XML, mostly. The API is fairly pythonic\n and supports some basic XPath features, but it lacks some DOM traversal\n niceties you might expect (e.g. to get an element's parent) and when using it\n you often feel like your working with something subtly different from XML,\n because you are.\n- `lxml `_ is a fast, full-featured XML library with an API\n based on ElementTree but extended. It is your best choice for doing serious\n work with XML in Python but it is not included in the standard library, it\n can be difficult to install, and it gives you the same it's-XML-but-not-quite\n feeling as its ElementTree forebear.\n\nGiven these three options it can be difficult to choose which library to use,\nespecially if you're new to XML processing in Python and haven't already\nused (struggled with) any of them.\n\nIn the past your best bet would have been to go with *lxml* for the most\nflexibility, even though it might be overkill, because at least then you\nwouldn't have to rewrite your code if you later find you need XPath support or\npowerful DOM traversal methods.\n\nThis is where *xml4h* comes in. It provides an abstraction layer over\nthe existing XML libraries, taking advantage of their power while offering an\nimproved API and tool set.\n\n\nThis project is heavily inspired by the work of\n`Kenneth Reitz `_ such as\nthe excellent `Requests HTTP library `_.\n\n\nDevelopment Status: beta\n------------------------\n\nCurrently *xml4h* includes adapter implementations for all three of the main\nXML processing Python libraries.\n\nIf you have *lxml* available (highly recommended) it will use that, otherwise\nit will fall back to use the *(c)ElementTree* then the *minidom* libraries.\n\n\nHistory\n-------\n\n0.2.0\n.....\n\n- Add adapter for the *(c)ElementTree* library versions included as standard\n with Python 2.7+.\n- Improved \"magical\" node traversal to work with lowercase tag names without\n always needing a trailing underscore. See also improved docs.\n- Fixes for: potential errors ASCII-encoding nodes as strings; default XPath\n namespace from document node; lookup precedence of xmlns attributes.\n\n\n0.1.0\n.....\n\n- Initial alpha release with support for *lxml* and *minidom* libraries.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/jmurty/xml4h", "keywords": null, "license": "Copyright (c) 2012, James Murty.\n\nPermission to use, copy, modify, and/or distribute this software for any\npurpose with or without fee is hereby granted, provided that the above\ncopyright notice and this permission notice appear in all copies.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES\nWITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF\nMERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR\nANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\nWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN\nACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF\nOR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.", "maintainer": null, "maintainer_email": null, "name": "xml4h", "package_url": "https://pypi.org/project/xml4h/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/xml4h/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/jmurty/xml4h" }, "release_url": "https://pypi.org/project/xml4h/0.2.0/", "requires_dist": null, "requires_python": null, "summary": "XML for Humans in Python", "version": "0.2.0" }, "last_serial": 753894, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "cd85f5f2e5e5379f33055a64840d51a0", "sha256": "f34d1c448fa0670352bcb3ff2126f8d2216fb6d1c8b916d34e9dcbb1ef66e371" }, "downloads": -1, "filename": "xml4h-0.1.0.tar.gz", "has_sig": false, "md5_digest": "cd85f5f2e5e5379f33055a64840d51a0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 57938, "upload_time": "2012-11-08T12:53:05", "url": "https://files.pythonhosted.org/packages/4c/01/2251d74f9552bf98b79f8cfc9e6e98940fc716091eb58ff20f4523cc07e0/xml4h-0.1.0.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "5571978a59dcbadfb478f6d8f22b4ca7", "sha256": "1de7d57f0fee36381193f99b1afe61cb04e896b25c9f992c737bccfe90578be3" }, "downloads": -1, "filename": "xml4h-0.2.0.tar.gz", "has_sig": false, "md5_digest": "5571978a59dcbadfb478f6d8f22b4ca7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 64310, "upload_time": "2013-06-05T22:25:31", "url": "https://files.pythonhosted.org/packages/fa/6d/93f97f218fdae68b8890a62aafc8e6e5e44a4d69bd87430217e0d1b229b9/xml4h-0.2.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "5571978a59dcbadfb478f6d8f22b4ca7", "sha256": "1de7d57f0fee36381193f99b1afe61cb04e896b25c9f992c737bccfe90578be3" }, "downloads": -1, "filename": "xml4h-0.2.0.tar.gz", "has_sig": false, "md5_digest": "5571978a59dcbadfb478f6d8f22b4ca7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 64310, "upload_time": "2013-06-05T22:25:31", "url": "https://files.pythonhosted.org/packages/fa/6d/93f97f218fdae68b8890a62aafc8e6e5e44a4d69bd87430217e0d1b229b9/xml4h-0.2.0.tar.gz" } ] }