Skip to content
This repository was archived by the owner on Jun 14, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,7 @@

##Install XMind SDK for python

Clone the repository to a local working directory

git clone https://github.com/xmindltd/xmind-sdk-python.git

Now there will be a directory named `xmind-sdk-python` under the current directory. Change to the directory `xmind-sdk-python` and install **XMind SDK for python**.

python setup.py install
pip install git+https://github.com/xmindltd/xmind-sdk-python.git

*It is highly recommended to install __XMind SDK for python__ under an isolated python environment using [virtualenv](https://pypi.python.org/pypi/virtualenv)*

Expand Down
42 changes: 42 additions & 0 deletions examples/dump.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#! /usr/bin/env python
# -*- coding: utf-8 -*-
#
# Author: hzsunshx
# Created: 2014-11-14 11:27

"""
dump xmind files
"""

import xmind
import pipes

M = {}

def _echo(tag, element, indent=0):
title = element.getTitle()
M[element.getID()] = title
print '\t'*indent, tag, ':', pipes.quote(title)

def dump_sheet(sheet):
rootTopic = sheet.getRootTopic()
_echo('RootTopic', rootTopic, 1)

for topic in rootTopic.getSubTopics() or []:
_echo('AttachedSubTopic', topic, 2)

for topic in rootTopic.getSubTopics(xmind.core.const.TOPIC_DETACHED) or []:
_echo('DetachedSubTopic', topic, 2)

for rel in sheet.getRelationships():
id1, id2 = rel.getEnd1ID(), rel.getEnd2ID()
print 'Relation: [%s] --> [%s]' % (M.get(id1), M.get(id2))

def main():
x = xmind.load('test2.xmind')
for sheet in x.getSheets():
_echo('Sheet', sheet)
dump_sheet(sheet)

if __name__ == '__main__':
main()
File renamed without changes.
Binary file added examples/test2.xmind
Binary file not shown.
1 change: 1 addition & 0 deletions xmind/core/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@

TOPIC_ROOT = "root"
TOPIC_ATTACHED = "attached"
TOPIC_DETACHED = "detached"

FILE_PROTOCOL = "file://"
TOPIC_PROTOCOL = "xmind:#"
Expand Down
7 changes: 7 additions & 0 deletions xmind/core/sheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ def createRelationship(self, end1, end2, title=None):

return rel

def getRelationships(self):
"""
Get relationships from current sheet
"""
elems = RelationshipsElement(self._getRelationships())
return map(RelationshipElement, elems.iterChildNodesByTagName(const.TAG_RELATIONSHIP))

def _getRelationships(self):
return self.getFirstChildNodeByTagName(const.TAG_RELATIONSHIPS)

Expand Down