mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-06-29 22:16:13 +02:00
Fix XML export
This commit is contained in:
parent
4adb5c252a
commit
b2542db5e5
3 changed files with 23 additions and 6 deletions
|
@ -28,6 +28,16 @@ class XMLExporter(JSONExporter):
|
|||
else:
|
||||
return entry_el
|
||||
|
||||
@classmethod
|
||||
def entry_to_xml(cls, entry, doc):
|
||||
entry_el = doc.createElement('entry')
|
||||
entry_el.setAttribute('date', entry.date.isoformat())
|
||||
if hasattr(entry, "uuid"):
|
||||
entry_el.setAttribute('uuid', u(entry.uuid))
|
||||
entry_el.setAttribute('starred', u(entry.starred))
|
||||
entry_el.appendChild(doc.createTextNode(entry.fulltext))
|
||||
return entry_el
|
||||
|
||||
@classmethod
|
||||
def export_journal(cls, journal):
|
||||
"""Returns an XML representation of an entire journal."""
|
||||
|
@ -36,12 +46,12 @@ class XMLExporter(JSONExporter):
|
|||
xml = doc.createElement('journal')
|
||||
tags_el = doc.createElement('tags')
|
||||
entries_el = doc.createElement('entries')
|
||||
for tag in tags:
|
||||
for count, tag in tags:
|
||||
tag_el = doc.createElement('tag')
|
||||
tag_el.setAttribute('name', tag[1])
|
||||
count_node = doc.createTextNode(u(tag[0]))
|
||||
tag.appendChild(count_node)
|
||||
tags_el.appendChild(tag)
|
||||
tag_el.setAttribute('name', tag)
|
||||
count_node = doc.createTextNode(u(count))
|
||||
tag_el.appendChild(count_node)
|
||||
tags_el.appendChild(tag_el)
|
||||
for entry in journal.entries:
|
||||
entries_el.appendChild(cls.entry_to_xml(entry, doc))
|
||||
xml.appendChild(entries_el)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue