[Python-modules-commits] [python-dicttoxml] 01/06: import dicttoxml_1.7.4.orig.tar.gz

Marcos Fouces mfouces-guest at moszumanska.debian.org
Tue Nov 29 22:18:56 UTC 2016


This is an automated email from the git hooks/post-receive script.

mfouces-guest pushed a commit to branch master
in repository python-dicttoxml.

commit 22223f9f2913fc409fe9f825438a12cd217ac0a2
Author: Marcos Fouces <mfouces at yahoo.es>
Date:   Sat Nov 26 08:33:09 2016 +0100

    import dicttoxml_1.7.4.orig.tar.gz
---
 LICENCE.txt     |  86 ++++++++
 PKG-INFO        | 643 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 README.markdown | 630 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 dicttoxml.py    | 400 +++++++++++++++++++++++++++++++++++
 setup.py        |  24 +++
 5 files changed, 1783 insertions(+)

diff --git a/LICENCE.txt b/LICENCE.txt
new file mode 100644
index 0000000..af3c0c5
--- /dev/null
+++ b/LICENCE.txt
@@ -0,0 +1,86 @@
+GNU GENERAL PUBLIC LICENSE
+
+Version 2, June 1991
+
+Copyright (C) 1989, 1991 Free Software Foundation, Inc.  
+51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
+
+Everyone is permitted to copy and distribute verbatim copies
+of this license document, but changing it is not allowed.
+
+Preamble
+
+The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General [...]
+
+When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things.
+
+To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it.
+
+For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.
+
+We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software.
+
+Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations.
+
+Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all.
+
+The precise terms and conditions for copying, distribution and modification follow.
+TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. ( [...]
+
+Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does.
+
+1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.
+
+2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. 
+    b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. 
+    c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself  [...]
+
+These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose p [...]
+
+Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.
+
+3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, 
+    b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, 
+    c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) 
+
+The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major co [...]
+
+If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code.
+
+4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.
+
+5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works ba [...]
+
+6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License.
+
+7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not dist [...]
+
+If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/dono [...]
+
+This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.
+
+8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.
+
+9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation.
+
+10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.
+
+NO WARRANTY
+
+11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  [...]
+
+12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO  [...]
diff --git a/PKG-INFO b/PKG-INFO
new file mode 100644
index 0000000..ae779eb
--- /dev/null
+++ b/PKG-INFO
@@ -0,0 +1,643 @@
+Metadata-Version: 1.1
+Name: dicttoxml
+Version: 1.7.4
+Summary: Converts a Python dictionary or other native data type into a valid XML string. 
+Home-page: https://github.com/quandyfactory/dicttoxml
+Author: Ryan McGreal
+Author-email: ryan at quandyfactory.com
+License: LICENCE.txt
+Download-URL: https://pypi.python.org/packages/source/d/dicttoxml/dicttoxml-1.7.4.tar.gz?raw=true
+Description: Summary
+        =======
+        
+        Converts a Python dictionary or other native data type into a valid XML string. 
+        
+        Details
+        =======
+        
+        Supports item (`int`, `float`, `long`, `decimal.Decimal`, `bool`, `str`, `unicode`, `datetime`, `none` and other number-like objects) and collection (`list`, `set`, `tuple` and `dict`, as well as iterable and dict-like objects) data types, with arbitrary nesting for the collections. Items with a `datetime` type are converted to ISO format strings. Items with a `None` type become empty XML elements.
+        
+        The root object passed into the `dicttoxml` method can be any of the supported data types.
+        
+        To satisfy XML syntax, the method prepends an `<?xml version="1.0" encoding="UTF-8" ?>` element and wraps the output in a `<root> ... </root>` element. However, this can be disabled to create XML snippets. Alternately, a custom root element can be specified by passing in the optional `custom_root=foobar` argument.
+        
+        For lists of items, if each item is also a collection data type (`lists`, `dict`), the elements of that item are wrapped in a generic `<item> ... </item>` element.
+        
+        Each element includes an optional `type` attribute with the data type. By default, the type attribute it included but it can be excluded by passing an optional `attr_type=False` argument when calling the `dicttoxml` method.
+        
+        Note: `datetime` data types are converted into ISO format strings, and `unicode` and `datetime` data types get a `str` attribute.
+        
+            Python -> XML
+            integer   int
+            long      long
+            float     float
+            Decimal   number
+            string    str
+            unicode   str
+            datetime  str
+            None      null
+            boolean   bool
+            list      list
+            set       list
+            tuple     list
+            dict      dict
+        
+        Elements with an unsupported data type raise a TypeError exception. 
+        
+        If an element name is invalid XML, it is rendered with the name "key" and the invalid name is included as a `name` attribute. E.g. `{ "^.{0,256}$": "foo" }` would be rendered `<key name="^.{0,256}$">foo</key>`. An exception is element names with spaces, which are converted to underscores.
+        
+        **This module should work in Python 2.6+ and Python 3.**
+        
+        Installation
+        ============
+        
+        The dicttoxml module is [published on the Python Package Index](https://pypi.python.org/pypi/dicttoxml), so you can install it using `pip` or `easy_install`.
+        
+            pip install dicttoxml
+            
+        Or:
+        
+            easy_install dicttoxml
+        
+        Alternately, you can download the tarballed installer - `dicttoxml-[VERSION].tar.gz` - for this package from the [dist](https://github.com/quandyfactory/dicttoxml/tree/master/dist) directory on github and uncompress it. Then, from a terminal or command window, navigate into the unzipped folder and type the command:
+        
+            python setup.py install
+            
+        That should be all you need to do.
+        
+        Basic Usage
+        ===========
+        
+        Once installed, import the library into your script and convert a dict into xml by running the `dicttoxml` function:
+        
+            >>> import dicttoxml
+            >>> xml = dicttoxml.dicttoxml(some_dict)
+        
+        Alternately, you can import the `dicttoxml()` function from the library.
+        
+            >>> from dicttoxml import dicttoxml
+            >>> xml = dicttoxml(some_dict)
+        
+        That's it!
+        
+        JSON to XML
+        ===========
+        
+        Let's say you want to fetch a JSON object from a URL and convert it into XML. Here's how you can do that:
+        
+            >>> import json
+            >>> import urllib
+            >>> import dicttoxml
+            >>> page = urllib.urlopen('http://quandyfactory.com/api/example')
+            >>> content = page.read()
+            >>> obj = json.loads(content)
+            >>> print(obj)
+            {u'mylist': [u'foo', u'bar', u'baz'], u'mydict': {u'foo': u'bar', u'baz': 1}, u'ok': True}
+            >>> xml = dicttoxml.dicttoxml(obj)
+            >>> print(xml)
+            <?xml version="1.0" encoding="UTF-8" ?><root><mylist><item type="str">foo</item><item type="str">bar</item><item type="str">baz</item></mylist><mydict><foo type="str">bar</foo><baz type="int">1</baz></mydict><ok type="bool">true</ok></root>
+        
+        It's that simple.
+        
+        Disable Type Attributes
+        =======================
+        
+        By default, dicttoxml includes a type attribute for each element. Starting in version 1.4, you can turn this off by passing an optional `attr_type=False` argument to the `dicttoxml` method. 
+        
+        Using our example:
+        
+            >>> xml = dicttoxml.dicttoxml(obj, attr_type=False)
+            >>> print(xml)
+            <?xml version="1.0" encoding="UTF-8" ?><root><mydict><foo>bar</foo><baz>1</baz></mydict><mylist><item>foo</item><item>bar</item><item>baz</item></mylist><ok>true</ok></root>
+        
+        As you can see, the only difference is that the type attributes are now absent.
+        
+        Custom Root
+        ===========
+        
+        By default, dicttoxml wraps all the elements in a `<root> ... </root>` element. Starting in version 1.5, you can change the name of the root element to something else by passing an optional `custom_root=some_custom_root` argument to the `dicttoxml` method.
+        
+        Using our example:
+        
+            >>> xml = dicttoxml.dicttoxml(obj, custom_root='some_custom_root')
+            >>> print(xml)
+            <?xml version="1.0" encoding="UTF-8" ?><some_custom_root><mydict><foo>bar</foo><baz>1</baz></mydict><mylist><item>foo</item><item>bar</item><item>baz</item></mylist><ok>true</ok></some_custom_root>
+        
+        As you can see, the name of the root element has changed to `some_custom_root`.
+        
+        XML Snippet
+        ===========
+        
+        You can also create an XML snippet for inclusion into another XML document, rather than a full XML document itself.
+        
+        Continuing with the example from above:
+        
+            >>> xml_snippet = dicttoxml.dicttoxml(obj, root=False)
+            >>> print(xml_snippet)
+            <mylist><item type="str">foo</item><item type="str">bar</item><item type="str">baz</item></mylist><mydict><foo type="str">bar</foo><baz type="int">1</baz></mydict><ok type="bool">true</ok>
+        
+        With the optional `root` argument set to `False`, the method converts the dict into XML without including an `<?xml>` prolog or a `<root>` element to enclose all the other elements.
+        
+        Pretty-Printing
+        ===============
+        
+        As they say, Python comes with batteries included. You can easily syntax-check and pretty-print your XML using Python's `xml.dom.minidom` module. 
+        
+        Again, continuing with our example:
+        
+            >>> from xml.dom.minidom import parseString
+            >>> dom = parseString(xml)
+            >>> print(dom.toprettyxml())
+            <?xml version="1.0" ?>
+            <root>
+                <mylist type="list">
+                    <item type="str">foo</item>
+                    <item type="str">bar</item>
+                    <item type="str">baz</item>
+                </mylist>
+                <mydict type="dict">
+                    <foo type="str">bar</foo>
+                    <baz type="int">1</baz>
+                </mydict>
+                <ok type="bool">true</ok>
+            </root>
+        
+        This makes the XML easier to read. If it is not well-formed, the xml parser will raise an exception.
+        
+        Unique ID Attributes
+        ====================
+        
+        Starting in version 1.1, you can set an optional `ids` parameter so that dicttoxml gives each element a unique `id` attribute. 
+        
+        With the `ids` flag on, the function generates a unique randomly-generated ID for each element based on the parent element in the form `parent_unique`. For list items, the id is in the form `parent_unique_index`.
+        
+        Continuing with our example:
+        
+            >>> xml_with_ids = dicttoxml.dicttoxml(obj, ids=True)
+            >>> print(parseString(xml_with_ids).toprettyxml())
+            <?xml version="1.0" ?>
+            <root>
+                    <mylist id="root_160980" type="list">
+                            <item id="mylist_609405_1" type="str">foo</item>
+                            <item id="mylist_609405_2" type="str">bar</item>
+                            <item id="mylist_609405_3" type="str">baz</item>
+                    </mylist>
+                    <mydict id="root_140407" type="dict">
+                            <foo id="mydict_260437" type="str">bar</foo>
+                            <baz id="mydict_111194" type="int">1</baz>
+                    </mydict>
+                    <ok id="root_612831" type="bool">true</ok>
+            </root>
+        
+        Note that the default XML output remains the same as previous, so as not to break compatibility for existing uses.
+        
+        Dict-Like and Iterable Objects
+        ==============================
+        
+        Starting in version 1.3, dicttoxml accepts dict-like objects that are derived from the `dict` base class and treats them like dicts. For example:
+        
+            >>> import collections
+            >>> dictlike = collections.OrderedDict({'foo': 1, 'bar': 2, 'baz': 3})
+            >>> xml = dicttoxml.dicttoxml(dictlike)
+            >>> print(xml)
+            <?xml version="1.0" encoding="UTF-8" ?><root><baz type="int">3</baz><foo type="int">1</foo><bar type="int">2</bar></root>
+        
+        Also starting in version 1.3, dicttoxml accepts iterable objects and treats them like lists. For example:
+        
+            >>> myiterator = xrange(1,11)
+            >>> xml = dicttoxml.dicttoxml(myiterator)
+            >>> print(xml)
+            <?xml version="1.0" encoding="UTF-8" ?><root><item type="int">1</item><item type="int">2</item><item type="int">3</item><item type="int">4</item><item type="int">5</item><item type="int">6</item><item type="int">7</item><item type="int">8</item><item type="int">9</item><item type="int">10</item></root>
+        
+        As always, this remains compatible with arbitrary nesting of objects and types.
+        
+        Define Custom Item Names
+        ========================
+        
+        Starting in version 1.7, if you don't want item elements in a list to be called 'item', you can specify the element name using a function that takes the parent element name (i.e. the list name) as an argument.
+        
+            >>> import dicttoxml
+            >>> obj = {u'mylist': [u'foo', u'bar', u'baz'], u'mydict': {u'foo': u'bar', u'baz': 1}, u'ok': True}
+            >>> my_item_func = lambda x: 'list_item'
+            >>> xml = dicttoxml.dicttoxml(obj, item_func=my_item_func)
+            >>> print(xml)
+            <?xml version="1.0" encoding="UTF-8" ?><root><mydict type="dict"><foo type="str">bar</foo><baz type="int">1</baz></mydict><mylist type="list"><list_item type="str">foo</list_item><list_item type="str">bar</list_item><list_item type="str">baz</list_item></mylist><ok type="bool">True</ok></root>
+        
+        The benefit of taking the parent element name as an argument is that you can write the function to do something with it. Let's say you have an object with some lists of specific items:
+        
+            >>> obj = {'shrubs': ['abelia', 'aralia', 'aucuba', 'azalea', 'bamboo', 'barberry', 'bluebeard', 'boxwood', 'camellia', 'dogwood', 'elderberry', 'enkianthus', 'firethorn', 'fuchsia', 'hazel', 'heath', 'heather', 'holly', 'honeysuckle', 'hydrangea', 'laurel', 'lilac', 'mock orange', 'rhododendron', 'rose', 'rose of sharon', 'rosemary', 'smokebush', 'spirea', 'sweetbox', 'viburnum', 'weigela', 'yucca'], 'trees': ['ash', 'aspen', 'birch', 'butternut', 'cedar', 'cottonwood', 'elm [...]
+        
+        You can define each item name to be the singular of its parent name by returning all but the last character.
+        
+            >>> my_item_func = lambda x: x[:-1]
+            >>> xml = dicttoxml.dicttoxml(obj, item_func=my_item_func)
+            >>> print(xml)
+            <?xml version="1.0" encoding="UTF-8" ?><root><shrubs type="list"><shrub type="str">abelia</shrub><shrub type="str">aralia</shrub><shrub type="str">aucuba</shrub><shrub type="str">azalea</shrub><shrub type="str">bamboo</shrub><shrub type="str">barberry</shrub><shrub type="str">bluebeard</shrub><shrub type="str">boxwood</shrub><shrub type="str">camellia</shrub><shrub type="str">dogwood</shrub><shrub type="str">elderberry</shrub><shrub type="str">enkianthus</shrub><shrub type="s [...]
+        
+        Of course, this can be combined with other optional arguments, like disabling type attributes or custom root element names.
+        
+        CDATA
+        =====
+        
+        Starting in version 1.7.1, you can wrap values in CDATA by setting the optional `cdata` argument to `True`.
+        
+            >>> import dicttoxml
+            >>> obj = {u'mylist': [u'foo', u'bar', u'baz'], u'mydict': {u'foo': u'bar', u'baz': 1}, u'ok': True}
+            >>> xml = dicttoxml.dicttoxml(obj, cdata=True)
+            >>> print(xml)
+            <?xml version="1.0" encoding="UTF-8" ?><root><mydict type="dict"><foo type="str"><![CDATA[bar]]></foo><baz type="int"><![CDATA[1]]></baz></mydict><mylist type="list"><item type="str"><![CDATA[foo]]></item><item type="str"><![CDATA[bar]]></item><item type="str"><![CDATA[baz]]></item></mylist><ok type="bool"><![CDATA[True]]></ok></root>
+        
+        If you do not set `cdata` to `True`, the default value is `False` and values are not wrapped.
+        
+        Debugging
+        =========
+        
+        You can enable debugging information.
+        
+            >>> import dicttoxml
+            >>> dicttoxml.set_debug()
+            Debug mode is on. Events are logged at: dicttoxml.log
+            >>> xml = dicttoxml.dicttoxml(some_dict)
+        
+        By default, debugging information is logged to `dicttoxml.log`, but you can change this:
+        
+            >>> dicttoxml.set_debug(filename='some_other_filename.log')
+            Debug mode is on. Events are logged at: some_other_filename.log
+        
+        To turn debug mode off, just call `set_debug` with an argument of `False`:
+        
+            >>> dicttoxml.set_debug(False)
+            Debug mode is off.
+        
+        If you encounter any errors in the code, please file an issue on github: [https://github.com/quandyfactory/dicttoxml/issues](https://github.com/quandyfactory/dicttoxml/issues).
+        
+        Author
+        ======
+        
+        * Author: Ryan McGreal
+        * Email: [ryan at quandyfactory.com](mailto:ryan at quandyfactory.com)
+        * Repository: [http://github.com/quandyfactory/dicttoxml](http://github.com/quandyfactory/dicttoxml)
+        
+        Version
+        =======
+        
+        * Version: 1.7.4
+        * Release Date: 2016-07-08
+        
+        Revision History
+        ================
+        
+        Version 1.7.4
+        -------------
+        
+        * Release Date: 2016-07-08
+        * Changes:
+            * Fixed [bug #46](https://github.com/quandyfactory/dicttoxml/issues/46) on github. Thanks to [robbincatz](https://github.com/robbincatz) for identifying and reporting the issue.
+        
+        Version 1.7.3
+        -------------
+        
+        * Release Date: 2016-07-07
+        * Changes:
+            * Updated README.markdown
+        
+        Version 1.7.2
+        -------------
+        
+        * Release Date: 2016-07-07
+        * Changes:
+            * XML-encodes values to avoid XML injection. Big thanks to [thomaskonrad](https://github.com/thomaskonrad) on Github, via [issue #41](https://github.com/quandyfactory/dicttoxml/issues/41).
+        
+        Version 1.7.1
+        -------------
+        
+        * Release Date: 2016-07-06
+        * Changes:
+            * Added ability to wrap values with CDATA. Big thanks to [LeviTaule](https://github.com/LeviTaule) on Github, via [pull request #45](https://github.com/quandyfactory/dicttoxml/pull/45/files).
+        
+        Version 1.7
+        -----------
+        
+        * Release Date: 2016-06-13
+        * Changes:
+            * First of all, sorry for such a log delay between releases! I have not been a responsible steward of this project and I aim to change that from now on. This is the first in a series of updates I will be pushing over the next couple of months to get caught up on the backlog of issues and pull requests.
+            * Added ability to customize `list` and `dict` item names via a function argument passed into the `dicttoxml()` function. Customizeable item name function takes the item's parent element as an argument. Big thanks to [viktor-zireael](https://github.com/viktor-zireael) on Github, via [pull request #40](https://github.com/quandyfactory/dicttoxml/pull/40/files).
+            * Updated code style to more closely follow PEP8.
+        
+        Version 1.6.6
+        -------------
+        
+        * Release Date: 2015-04-09
+        * Changes:
+            * PyPi does not want to upload version 1.6.5. It's returning an `Upload failed (500): Internal Server Error` message when I try to upload the code. I'm incrementing the version by one and reinstalling it to see if that fixes the issue.
+        
+        Version 1.6.5
+        -------------
+        
+        * Release Date: 2015-04-09
+        * Changes:
+            * Fixed [issue #37](https://github.com/quandyfactory/dicttoxml/issues/37), elements with boolean values were getting a "number" type attribute. The issue was that `isinstance(True, numbers.Number)` returns `True`. I modified the `get_xml_type()` function to test for `boolean` before testing for `numbers.Number`. Thanks to [badsequel](https://github.com/badsequel) for identifying and reporting the issue.
+        
+        Version 1.6.4
+        -------------
+        
+        * Release Date: 2015-03-11
+        * Changes:
+            * Fixed [issue #36](https://github.com/quandyfactory/dicttoxml/issues/36), logging was throwing an UnicodeDecodeError on non-ASCII characters in dictionary values. Thanks to [beef9999](https://github.com/beef9999) for identifying and reporting the issue.
+        
+        Version 1.6.3
+        -------------
+        
+        * Release Date: 2015-03-05
+        * Changes:
+            * Updated README.markdown to reflect changes made in v. 1.6.2.
+        
+        Version 1.6.2
+        -------------
+        
+        * Release Date: 2015-03-05
+        * Changes:
+            * Fixed [issue #35](https://github.com/quandyfactory/dicttoxml/issues/35), dicttoxml fails to identify a `decimal.Decimal` as a number. This is done by replacing `type(val).__name__ in ('int', 'long')` with the more generic `isinstance(val, number.Number)`. Thanks to [jmagnusson](https://github.com/jmagnusson) for finding and fixing the error.
+        
+        Version 1.6.1
+        -------------
+        
+        * Release Date: 2015-03-05
+        * Changes:
+            * Merged [pull request #34](https://github.com/quandyfactory/dicttoxml/pull/34), fix misleading TypeError in `convert_dict()`. Thanks to [jmagnusson](https://github.com/jmagnusson) for finding and fixing the error.
+        
+        Version 1.6.0
+        -------------
+        
+        * Release Date: 2015-02-23
+        * Changes:
+            * Fixed [issue #32](https://github.com/quandyfactory/dicttoxml/issues/32), duplication in test for list-like data types.
+        
+        Version 1.5.9
+        -------------
+        
+        * Release Date: 2015-02-23
+        * Changes:
+            * Merged [pull request #33](https://github.com/quandyfactory/dicttoxml/pull/33) to replace invocations of `logging` with `LOG`. Thanks to [mfriedenhagen ](https://github.com/mfriedenhagen) for identifying the issue with the logger, and to [seyhuns](https://github.com/seyhuns) for supplying a pull request that could be merged automatically.
+        
+        Version 1.5.8
+        -------------
+        
+        * Release Date: 2015-01-06
+        * Changes:
+            * Fixed [issue #30](https://github.com/quandyfactory/dicttoxml/issues/30) via [pull request #31](https://github.com/quandyfactory/dicttoxml/pull/31). Thanks to [isaac-councill](https://github.com/isaac-councill) for identifying the issue and providing a fix.
+        
+        Version 1.5.7
+        -------------
+        
+        * Release Date: 2014-12-09
+        * Changes:
+            * Fixed [issue #29](https://github.com/quandyfactory/dicttoxml/issues/29). Thanks to [birdsarah](https://github.com/birdsarah) for identifying this performance issue and providing a fix.
+        
+        Version 1.5.6
+        -------------
+        
+        * Release Date: 2014-08-18
+        * Changes:
+            * Fixed [issue #24](https://github.com/quandyfactory/dicttoxml/issues/24). Thanks to [gdude2002](https://github.com/gdude2002) for identifying the issue.
+            * Abstracted all XML validity tests to a single function `make_valid_xml_name(key, attr)`
+        
+        Version 1.5.5
+        -------------
+        
+        * Release Date: 2014-06-16
+        * Changes:
+            * Fixed [issue #21](https://github.com/quandyfactory/dicttoxml/pull/21). Thanks to [lichenbo](https://github.com/lichenbo) for identifying the issue and providing a fix.
+            * Abstracted setting XML type attribute into a function, `get_xml_type()`.
+            * Standardized variable names inside functions (e.g. `k` -> `key`, `v` -> `val`).
+            * Cleaned up README so it works as both Markdown (for github) and ReStructuredText (for PyPi)
+        
+        Version 1.5.4
+        -------------
+        
+        * Release Date: 2014-06-03
+        * Changes:
+            * Fixed [issue #20](https://github.com/quandyfactory/dicttoxml/issues/20).  Thanks to [lichenbo](https://github.com/lichenbo) for identifying the issue and providing a fix.
+        
+        Version 1.5.3
+        -------------
+        
+        * Release Date: 2014-06-08
+        * Changes:
+            * Minor updates to README.markdown
+        
+        Version 1.5.2
+        -------------
+        
+        * Release Date: 2014-06-03
+        * Changes:
+            * Minor updates to README.markdown
+        
+        Version 1.5.1
+        -------------
+        
+        * Release Date: 2014-06-03
+        * Changes:
+            * Minor updates to README.markdown
+        
+        Version 1.5
+        -----------
+        
+        * Release Date: 2014-06-03
+        * Changes:
+            * Added ability to set a custom root element, as per [issue #18](https://github.com/quandyfactory/dicttoxml/issues/18) by [murielsilveira](https://github.com/murielsilveira).
+        
+        Version 1.4
+        -----------
+        
+        * Release Date: 2014-06-03
+        * Changes:
+            * Element type attribute made optional via pull request from [gauravub](https://github.com/gauravub] to resolve [issue #17](https://github.com/quandyfactory/dicttoxml/pull/17).
+        
+        Version 1.3.7
+        -------------
+        
+        * Release Date: 2014-04-21
+        * Changes:
+            * Updated `MANIFEST.in` and `setup.py` so the licence and readme are properly included in the distribution.
+        
+        Version 1.3.6
+        -------------
+        
+        * Release Date: 2014-04-21
+        * Changes:
+            * Added `MANIFEST.in` to include the `LICENCE.txt` and `README.markdown` files in the distribution, as per [issue #15](https://github.com/quandyfactory/dicttoxml/issues/15).
+        
+        Version 1.3.5
+        -------------
+        
+        * Release Date: 2014-04-14
+        * Changes:
+            * `dicttoxml()` accepts `[None]` as a parameter and returns a valid XML object, as per [issue #13](https://github.com/quandyfactory/dicttoxml/issues/13).
+        
+        Version 1.3.4
+        -------------
+        
+        * Release Date: 2014-04-14
+        * Changes:
+            * `dicttoxml()` now accepts `None` as a parameter and returns a valid XML object, as per [issue #13](https://github.com/quandyfactory/dicttoxml/issues/13).
+        
+        Version 1.3.3
+        -------------
+        
+        * Release Date: 2014-04-14
+        * Changes:
+            * Automatically converts spaces in key names to underscores, as per [issue #12](https://github.com/quandyfactory/dicttoxml/pull/12).
+        
+        Version 1.3.2
+        -------------
+        
+        * Release Date: 2014-04-14
+        * Changes:
+            * Added convert_none() function to convert a null value into XML
+            * Added `key_is_valid_xml()` function to test if a key is valid XML
+            * Updated `convert_kv()`, `convert_bool()` and `convert_none()` functions to test whether the key is a valid XML name and, if it is not, to render it as `<key name="{invalidname}">value</key>`. This addresses [issue 10](https://github.com/quandyfactory/dicttoxml/issues/10).
+        
+        Version 1.3.1
+        -------------
+        
+        * Release Date: 2013-07-12
+        * Changes:
+            * Updated README to note support for dict-like and iterable objects.
+        
+        Version 1.3
+        -----------
+        
+        * Release Date: 2013-07-12
+        * Changes:
+            * changed test for dict type from `type(x)=dict` to `isinstance(x,dict)` to include dict-like subclases derived from dict, as per [issue 9](https://github.com/quandyfactory/dicttoxml/issues/9).
+            * Added test for `isinstance(x,collections.Iterable)` to test for list, set, tuple to accommodate iterable objects, as per [issue 9](https://github.com/quandyfactory/dicttoxml/issues/9).
+        
+        Version 1.2
+        -----------
+        
+        * Release Date: 2013-07-11
+        * Changes:
+            * Fixed typo in convert_list() exception raise as per [issue 8](https://github.com/quandyfactory/dicttoxml/issues/8).
+        
+        Version 1.1.2
+        -------------
+        
+        * Release Date: 2013-05-06
+        * Changes:
+            * Renamed github repo from dict2xml to dicttoxml to match PyPI name.
+        
+        Version 1.1.1
+        -------------
+        
+        * Release Date: 2013-05-06
+        * Changes:
+            * Fixed README.markdown
+        
+        Version 1.1
+        -----------
+        
+        * Release Date: 2013-05-06
+        * Changes:
+            * Added an optional `ids` argument to give each element a unique, randomly generated id attribute.
+            * All elements now inlcude a `type` attribute.
+            * Updated readme with more examples and Python 3 compatible syntax.
+            * Thanks to [cpetz](https://github.com/cpetz) for [suggesting](https://github.com/quandyfactory/dicttoxml/issues/7) this feature.
+        
+        Verson 1.0
+        ----------
+        
+        * Release Date: 2013-03-04
+        * Changes:
+            * Replaced debug function with `logging` module.
+            * Converted code to work in Python 2.6+ and Python 3.
+            * Fixed unresolved isoformat reference in `convert_list`.
+            * Bug thanks to [regisd](https://github.com/regisd) for forking code and making several important fixes!
+        
+        Version 0.9.1
+        -------------
+        
+        * Release Date: 2013-03-03
+        * Changes:
+            * Merged [pull request](https://github.com/quandyfactory/dicttoxml/pull/5) from [regisd](https://github.com/regisd) to fix [issue #5](https://github.com/quandyfactory/dicttoxml/issues/5), in which special XML characters were not being escaped properly.
+        
+        Version 0.9
+        -----------
+        
+        * Release Date: 2013-02-27
+        * Changes:
+            * Added support for tuples.
+        
+        Version 0.8
+        -----------
+        
+        * Release Date: 2013-02-23
+        * Changes:
+            * Changed name to dicttoxml and published to the Python Package Index (PyPI).
+        
+        Version 0.7
+        -----------
+        
+        * Release Date: 2012-09-12
+        * Changes:
+            * Fixed [issue #4](https://github.com/quandyfactory/dicttoxml/issues/4) - thanks to PaulMdx for finding it and suggesting a fix.
+        
+        Version 0.6
+        -----------
+        
+        * Release Date: 2012-07-13
+        * Changes: 
+            * Merged pull request from [0902horn](https://github.com/0902horn/dicttoxml) on github to escape special XML characters.
+        
+        Version 0.5
+        -----------
+        
+        * Release Date: 2012-02-28
+        * Changes: 
+            * Added support for datetime objects (converts them into ISO format strings) and sets (converts them into lists).
+            * Fixed [bug 2](https://github.com/quandyfactory/dicttoxml/issues/2) by raising an exception on unsupported data types.
+        
+        Version 0.4
+        -----------
+        
+        * Release Date: 2012-01-26
+        * Changes: 
+            * Added optional `root` argument (default `True`) on whether to wrap the generated XML in an XML declaration and a root element.
+            * Added ability to convert a root object of other data types - int, float, str, unicode, list - as well as dict.
+            * Corrected `license` attribute in `setup.py`.
+            * Renamed `notify()` function to `debug_notify()` and made it more comprehensive.
+        
+        Version 0.3
+        -----------
+        
+        * Release Date: 2012-01-24
+        * Changes: 
+            * Fixed inconsistent str/string attributes.
+        
+        Version 0.2
+        -----------
+        
+        * Release Date: 2012-01-24
+        * Changes: 
+            * Fixed bug in list items.
+            * Added element attribute with data type.
+        
+        Version 0.1
+        -----------
+        
+        * Release Date: 2012-01-24
+        * Changes: 
+            * First commit.
+        
+        Copyright and Licence
+        =====================
+        
+        Copyright 2012 by Ryan McGreal. 
+        
+        Released under the GNU General Public Licence, Version 2:  
+        <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>
+        
+        
+Platform: Cross-platform
+Classifier: Programming Language :: Python
+Classifier: Programming Language :: Python :: 3
diff --git a/README.markdown b/README.markdown
new file mode 100644
index 0000000..973a656
--- /dev/null
+++ b/README.markdown
@@ -0,0 +1,630 @@
+Summary
+=======
+
+Converts a Python dictionary or other native data type into a valid XML string. 
+
+Details
+=======
+
+Supports item (`int`, `float`, `long`, `decimal.Decimal`, `bool`, `str`, `unicode`, `datetime`, `none` and other number-like objects) and collection (`list`, `set`, `tuple` and `dict`, as well as iterable and dict-like objects) data types, with arbitrary nesting for the collections. Items with a `datetime` type are converted to ISO format strings. Items with a `None` type become empty XML elements.
+
+The root object passed into the `dicttoxml` method can be any of the supported data types.
+
+To satisfy XML syntax, the method prepends an `<?xml version="1.0" encoding="UTF-8" ?>` element and wraps the output in a `<root> ... </root>` element. However, this can be disabled to create XML snippets. Alternately, a custom root element can be specified by passing in the optional `custom_root=foobar` argument.
+
+For lists of items, if each item is also a collection data type (`lists`, `dict`), the elements of that item are wrapped in a generic `<item> ... </item>` element.
+
+Each element includes an optional `type` attribute with the data type. By default, the type attribute it included but it can be excluded by passing an optional `attr_type=False` argument when calling the `dicttoxml` method.
+
+Note: `datetime` data types are converted into ISO format strings, and `unicode` and `datetime` data types get a `str` attribute.
+
+    Python -> XML
+    integer   int
+    long      long
+    float     float
+    Decimal   number
+    string    str
+    unicode   str
+    datetime  str
+    None      null
+    boolean   bool
+    list      list
+    set       list
+    tuple     list
+    dict      dict
+
+Elements with an unsupported data type raise a TypeError exception. 
+
+If an element name is invalid XML, it is rendered with the name "key" and the invalid name is included as a `name` attribute. E.g. `{ "^.{0,256}$": "foo" }` would be rendered `<key name="^.{0,256}$">foo</key>`. An exception is element names with spaces, which are converted to underscores.
+
+**This module should work in Python 2.6+ and Python 3.**
+
+Installation
+============
+
+The dicttoxml module is [published on the Python Package Index](https://pypi.python.org/pypi/dicttoxml), so you can install it using `pip` or `easy_install`.
+
+    pip install dicttoxml
+    
+Or:
+
+    easy_install dicttoxml
+
+Alternately, you can download the tarballed installer - `dicttoxml-[VERSION].tar.gz` - for this package from the [dist](https://github.com/quandyfactory/dicttoxml/tree/master/dist) directory on github and uncompress it. Then, from a terminal or command window, navigate into the unzipped folder and type the command:
+
+    python setup.py install
+    
+That should be all you need to do.
+
+Basic Usage
+===========
+
+Once installed, import the library into your script and convert a dict into xml by running the `dicttoxml` function:
+
+    >>> import dicttoxml
+    >>> xml = dicttoxml.dicttoxml(some_dict)
+
+Alternately, you can import the `dicttoxml()` function from the library.
+
+    >>> from dicttoxml import dicttoxml
+    >>> xml = dicttoxml(some_dict)
+
+That's it!
+
+JSON to XML
+===========
+
+Let's say you want to fetch a JSON object from a URL and convert it into XML. Here's how you can do that:
+
+    >>> import json
+    >>> import urllib
+    >>> import dicttoxml
+    >>> page = urllib.urlopen('http://quandyfactory.com/api/example')
+    >>> content = page.read()
+    >>> obj = json.loads(content)
+    >>> print(obj)
+    {u'mylist': [u'foo', u'bar', u'baz'], u'mydict': {u'foo': u'bar', u'baz': 1}, u'ok': True}
+    >>> xml = dicttoxml.dicttoxml(obj)
+    >>> print(xml)
+    <?xml version="1.0" encoding="UTF-8" ?><root><mylist><item type="str">foo</item><item type="str">bar</item><item type="str">baz</item></mylist><mydict><foo type="str">bar</foo><baz type="int">1</baz></mydict><ok type="bool">true</ok></root>
+
+It's that simple.
+
+Disable Type Attributes
+=======================
+
+By default, dicttoxml includes a type attribute for each element. Starting in version 1.4, you can turn this off by passing an optional `attr_type=False` argument to the `dicttoxml` method. 
+
+Using our example:
+
+    >>> xml = dicttoxml.dicttoxml(obj, attr_type=False)
+    >>> print(xml)
+    <?xml version="1.0" encoding="UTF-8" ?><root><mydict><foo>bar</foo><baz>1</baz></mydict><mylist><item>foo</item><item>bar</item><item>baz</item></mylist><ok>true</ok></root>
+
+As you can see, the only difference is that the type attributes are now absent.
+
+Custom Root
+===========
+
+By default, dicttoxml wraps all the elements in a `<root> ... </root>` element. Starting in version 1.5, you can change the name of the root element to something else by passing an optional `custom_root=some_custom_root` argument to the `dicttoxml` method.
+
+Using our example:
+
+    >>> xml = dicttoxml.dicttoxml(obj, custom_root='some_custom_root')
+    >>> print(xml)
+    <?xml version="1.0" encoding="UTF-8" ?><some_custom_root><mydict><foo>bar</foo><baz>1</baz></mydict><mylist><item>foo</item><item>bar</item><item>baz</item></mylist><ok>true</ok></some_custom_root>
+
+As you can see, the name of the root element has changed to `some_custom_root`.
+
+XML Snippet
+===========
+
+You can also create an XML snippet for inclusion into another XML document, rather than a full XML document itself.
+
+Continuing with the example from above:
+
+    >>> xml_snippet = dicttoxml.dicttoxml(obj, root=False)
+    >>> print(xml_snippet)
+    <mylist><item type="str">foo</item><item type="str">bar</item><item type="str">baz</item></mylist><mydict><foo type="str">bar</foo><baz type="int">1</baz></mydict><ok type="bool">true</ok>
+
+With the optional `root` argument set to `False`, the method converts the dict into XML without including an `<?xml>` prolog or a `<root>` element to enclose all the other elements.
+
+Pretty-Printing
+===============
+
+As they say, Python comes with batteries included. You can easily syntax-check and pretty-print your XML using Python's `xml.dom.minidom` module. 
+
+Again, continuing with our example:
+
+    >>> from xml.dom.minidom import parseString
+    >>> dom = parseString(xml)
+    >>> print(dom.toprettyxml())
+    <?xml version="1.0" ?>
+    <root>
+        <mylist type="list">
+            <item type="str">foo</item>
+            <item type="str">bar</item>
+            <item type="str">baz</item>
+        </mylist>
+        <mydict type="dict">
+            <foo type="str">bar</foo>
+            <baz type="int">1</baz>
+        </mydict>
+        <ok type="bool">true</ok>
+    </root>
+
+This makes the XML easier to read. If it is not well-formed, the xml parser will raise an exception.
+
+Unique ID Attributes
+====================
+
+Starting in version 1.1, you can set an optional `ids` parameter so that dicttoxml gives each element a unique `id` attribute. 
+
+With the `ids` flag on, the function generates a unique randomly-generated ID for each element based on the parent element in the form `parent_unique`. For list items, the id is in the form `parent_unique_index`.
+
+Continuing with our example:
+
+    >>> xml_with_ids = dicttoxml.dicttoxml(obj, ids=True)
+    >>> print(parseString(xml_with_ids).toprettyxml())
+    <?xml version="1.0" ?>
+    <root>
+            <mylist id="root_160980" type="list">
+                    <item id="mylist_609405_1" type="str">foo</item>
+                    <item id="mylist_609405_2" type="str">bar</item>
+                    <item id="mylist_609405_3" type="str">baz</item>
+            </mylist>
+            <mydict id="root_140407" type="dict">
+                    <foo id="mydict_260437" type="str">bar</foo>
+                    <baz id="mydict_111194" type="int">1</baz>
+            </mydict>
+            <ok id="root_612831" type="bool">true</ok>
+    </root>
+
+Note that the default XML output remains the same as previous, so as not to break compatibility for existing uses.
+
+Dict-Like and Iterable Objects
+==============================
+
+Starting in version 1.3, dicttoxml accepts dict-like objects that are derived from the `dict` base class and treats them like dicts. For example:
+
+    >>> import collections
+    >>> dictlike = collections.OrderedDict({'foo': 1, 'bar': 2, 'baz': 3})
+    >>> xml = dicttoxml.dicttoxml(dictlike)
+    >>> print(xml)
+    <?xml version="1.0" encoding="UTF-8" ?><root><baz type="int">3</baz><foo type="int">1</foo><bar type="int">2</bar></root>
+
+Also starting in version 1.3, dicttoxml accepts iterable objects and treats them like lists. For example:
+
+    >>> myiterator = xrange(1,11)
+    >>> xml = dicttoxml.dicttoxml(myiterator)
+    >>> print(xml)
+    <?xml version="1.0" encoding="UTF-8" ?><root><item type="int">1</item><item type="int">2</item><item type="int">3</item><item type="int">4</item><item type="int">5</item><item type="int">6</item><item type="int">7</item><item type="int">8</item><item type="int">9</item><item type="int">10</item></root>
+
+As always, this remains compatible with arbitrary nesting of objects and types.
+
+Define Custom Item Names
+========================
+
+Starting in version 1.7, if you don't want item elements in a list to be called 'item', you can specify the element name using a function that takes the parent element name (i.e. the list name) as an argument.
+
+    >>> import dicttoxml
+    >>> obj = {u'mylist': [u'foo', u'bar', u'baz'], u'mydict': {u'foo': u'bar', u'baz': 1}, u'ok': True}
+    >>> my_item_func = lambda x: 'list_item'
+    >>> xml = dicttoxml.dicttoxml(obj, item_func=my_item_func)
+    >>> print(xml)
+    <?xml version="1.0" encoding="UTF-8" ?><root><mydict type="dict"><foo type="str">bar</foo><baz type="int">1</baz></mydict><mylist type="list"><list_item type="str">foo</list_item><list_item type="str">bar</list_item><list_item type="str">baz</list_item></mylist><ok type="bool">True</ok></root>
+
+The benefit of taking the parent element name as an argument is that you can write the function to do something with it. Let's say you have an object with some lists of specific items:
+
+    >>> obj = {'shrubs': ['abelia', 'aralia', 'aucuba', 'azalea', 'bamboo', 'barberry', 'bluebeard', 'boxwood', 'camellia', 'dogwood', 'elderberry', 'enkianthus', 'firethorn', 'fuchsia', 'hazel', 'heath', 'heather', 'holly', 'honeysuckle', 'hydrangea', 'laurel', 'lilac', 'mock orange', 'rhododendron', 'rose', 'rose of sharon', 'rosemary', 'smokebush', 'spirea', 'sweetbox', 'viburnum', 'weigela', 'yucca'], 'trees': ['ash', 'aspen', 'birch', 'butternut', 'cedar', 'cottonwood', 'elm', 'fir' [...]
+
+You can define each item name to be the singular of its parent name by returning all but the last character.
+
+    >>> my_item_func = lambda x: x[:-1]
+    >>> xml = dicttoxml.dicttoxml(obj, item_func=my_item_func)
+    >>> print(xml)
+    <?xml version="1.0" encoding="UTF-8" ?><root><shrubs type="list"><shrub type="str">abelia</shrub><shrub type="str">aralia</shrub><shrub type="str">aucuba</shrub><shrub type="str">azalea</shrub><shrub type="str">bamboo</shrub><shrub type="str">barberry</shrub><shrub type="str">bluebeard</shrub><shrub type="str">boxwood</shrub><shrub type="str">camellia</shrub><shrub type="str">dogwood</shrub><shrub type="str">elderberry</shrub><shrub type="str">enkianthus</shrub><shrub type="str">fire [...]
+
+Of course, this can be combined with other optional arguments, like disabling type attributes or custom root element names.
+
+CDATA
+=====
+
+Starting in version 1.7.1, you can wrap values in CDATA by setting the optional `cdata` argument to `True`.
+
+    >>> import dicttoxml
+    >>> obj = {u'mylist': [u'foo', u'bar', u'baz'], u'mydict': {u'foo': u'bar', u'baz': 1}, u'ok': True}
+    >>> xml = dicttoxml.dicttoxml(obj, cdata=True)
+    >>> print(xml)
+    <?xml version="1.0" encoding="UTF-8" ?><root><mydict type="dict"><foo type="str"><![CDATA[bar]]></foo><baz type="int"><![CDATA[1]]></baz></mydict><mylist type="list"><item type="str"><![CDATA[foo]]></item><item type="str"><![CDATA[bar]]></item><item type="str"><![CDATA[baz]]></item></mylist><ok type="bool"><![CDATA[True]]></ok></root>
+
... 826 lines suppressed ...

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-dicttoxml.git



More information about the Python-modules-commits mailing list