Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
X
xml_marshaller
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
xml_marshaller
Commits
c59d1057
Commit
c59d1057
authored
Oct 30, 2010
by
Nicolas Delaby
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add description and example in README.txt
parent
b92fe755
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
2 deletions
+60
-2
CHANGES.txt
CHANGES.txt
+1
-1
README.txt
README.txt
+59
-1
No files found.
CHANGES.txt
View file @
c59d1057
...
@@ -5,7 +5,7 @@ History
...
@@ -5,7 +5,7 @@ History
------------------
------------------
0.9.7 (2010-10-
28
)
0.9.7 (2010-10-
30
)
---------------------
---------------------
- Enhance egg folder structure
- Enhance egg folder structure
[nicolas Delaby]
[nicolas Delaby]
...
...
README.txt
View file @
c59d1057
Introduction
============
Marshals simple Python data types into a custom XML format.
Marshals simple Python data types into a custom XML format.
The Marshaller and Unmarshaller classes can be subclassed in order
The Marshaller and Unmarshaller classes can be subclassed in order
to implement marshalling into a different XML DTD.
to implement marshalling into a different XML DTD.
Original Authors are XML-SIG (xml-sig@python.org).
Original Authors are XML-SIG (xml-sig@python.org).
Fully compatible with PyXML implementation, enable namespace support for
Fully compatible with PyXML implementation, enable namespace support for
XML Input/Output.
XML Input/Output.
Implemented with lxml
\ No newline at end of file
Implemented with lxml
Installation
============
python setup.py install
Testing
=======
python setup.py test
Usage
=====
For simple serialisation and unserialisation::
>>> from xml_marshaller import xml_marshaller
>>> xml_marshaller.dumps(['item1', {'key1': 1, 'key2': u'unicode string'}])
'<marshal><list id="i2"><string>item1</string><dictionary id="i3"><string>key1</string><int>1</int><string>key2</string><unicode>unicode string</unicode></dictionary></list></marshal>'
>>> xml_marshaller.loads(xml_marshaller.dumps(['item1', {'key1': 1, 'key2': u'unicode string'}]))
['item1', {'key2': u'unicode string', 'key1': 1}]
Can works with file like objects::
>>> from xml_marshaller import xml_marshaller
>>> from StringIO import StringIO
>>> file_like_object = StringIO()
>>> xml_marshaller.dump('Hello World !', file_like_object)
>>> file_like_object.seek(0)
>>> file_like_object.read()
'<marshal><string>Hello World !</string></marshal>'
>>> file_like_object.seek(0)
>>> xml_marshaller.load(file_like_object)
'Hello World !'
xml_marshaller can also output xml with qualified names::
>>> from xml_marshaller import xml_marshaller
>>> xml_marshaller.dumps_ns('Hello World !')
'<marshal:marshal xmlns:marshal="http://www.erp5.org/namespaces/marshaller"><marshal:string>Hello World !</marshal:string></marshal:marshal>'
You can also use your own URI::
>>> from xml_marshaller.xml_marshaller import Marshaller
>>> marshaller = Marshaller(namespace_uri='http://my-custom-namespace-uri/namespace')
>>> marshaller.dumps('Hello World !')
'<marshal:marshal xmlns:marshal="http://my-custom-namespace-uri/namespace"><marshal:string>Hello World !</marshal:string></marshal:marshal>'
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment