【未经允许,禁止转载和引用!!!!!】
前情
兼容性测试:主要测试了2010,2018,2023,2024,XMind 8版本。
问题
做项目的时候需要用Python去读取xmind文件,并将xmind转化为plantuml格式。使用Python自带库即可解决以上问题。但是测试了几个不同版本的xmind文件,发现兼容性不好,除了用XMind 8保存的版本外,其余多个版本读取的时候出现以下情况(如图1所示),输出的不是文件内容,而是xmind的警告信息。而我想要xmind的内容哇,怎么弄?Python的xmind库只支持解析xmind8 文件,但是不同客户给的xmind文件版本很难统一。。。
简易读取xmind代码:
import xmind
def read_xmind(file_path):
workbook = xmind.load(file_path)
sheets = workbook.getSheets()
for sheet in sheets:
print("Sheet:", sheet.getTitle())
root_topic = sheet.getRootTopic()
print_topic(root_topic)
def print_topic(topic, indent=0):
print(' ' * indent + topic.getTitle())
if topic.getNotes():
print(' ' * (indent + 1) + "Notes:")
print(' ' * (indent + 1) + topic.getNotes())
for child