diff --git a/simplexml/core.py b/simplexml/core.py
index de8af95..2958f28 100644
--- a/simplexml/core.py
+++ b/simplexml/core.py
@@ -115,7 +115,7 @@ def dict_from_element(element, dic):
return dic
-def dumps(data):
+def dumps(data, pretty=False):
data_items = [(key, values) for key, values in data.items()]
rootName, rootValue = data_items[0]
@@ -130,6 +130,8 @@ def dumps(data):
element_from_dict(document, rootNode, rootValue)
+ if pretty == True:
+ return document.toprettyxml()
return document.toxml()
def loads(data):
diff --git a/tests/test_core.py b/tests/test_core.py
index d0fc2fa..45ed7fa 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -108,3 +108,10 @@ def test_can_dumps_with_first_node_list():
response = simplexml.dumps(sometag)
assert 'Should Be NomeShould Be Nome' in response
+
+def test_can_dumps_with_pretty():
+
+ sometag = {'someTags': [{'someTag': {'nome': 'Should Be Nome'}}, {'someTag': {'nome': 'Should Be Nome'}}]}
+ response = simplexml.dumps(sometag, pretty=True)
+
+ assert '\n\n\t\n\t\tShould Be Nome\n\t\n\t\n\t\tShould Be Nome\n\t\n\n' in response
\ No newline at end of file