xmind內容主要結構是以json格式構成的,將.xmind文件后綴改成.zip,可以看見一個content.json文件,整個思維導圖的內容及結構就在這個文件中。
本小項目所用xmind用例模板如圖:
圖標含義:
- 開始圖標表示前置條件("markerId": "task-start")
- 數字圖標表示用例及優先級("markerId": "priority-3")
將其后綴改為.zip,打開可見一個content.json文件,里面即為xmind內容及組成結構:
打開該文件,可以用JSON在線解析及格式化驗證工具(https://www.json.cn/)格式化一下,方便觀察結構組成:
[
{
"id":"5aebd6f249aa3e09c508bba69b",
"class":"sheet",
"title":"畫布 1",
"rootTopic":{
"id":"b9aa22deba98b3b20c7ac8aca2",
"class":"topic",
"title":"根目錄,不導入",
"structureClass":"org.xmind.ui.map.unbalanced",
"children":{
"attached":[
{
"id":"b58888b5ceebbf0e68dada0656",
"title":"模塊1",
"children":{
"attached":[
{
"id":"86d91b46-78b0-4be0-adc5-28c5de6d1176",
"title":"這是前置條件,前面需要加圖標",
"markers":[
{
"markerId":"task-start"
}
],
"children":{
"attached":[
{
"id":"c6100b2e-1a29-490d-920c-4514a2bc96d8",
"title":"這是用例名,需要加圖標1-4",
"markers":[
{
"markerId":"priority-3"
}
],
"children":{
"attached":[
{
"id":"31edfe34-d973-404e-bde3-6ce06c82882f",
"title":"步驟1",
"children":{
"attached":[
{
"id":"5851a9b0-5546-4e58-a4a8-2bf535feb2fc",
"title":"結果1"
}
]
}
},
{
"id":"7fcce725-a816-4831-92a2-2996c5285124",
"title":"結果2"
},
{
"id":"fec20ab8-caec-4bd0-a41e-e35c13e9354b",
"title":"步驟3",
"children":{
"attached":[
{
"id":"c3c53f4e-4299-47dc-b2a1-844a3a878b15",
"title":"結果3"
}
]
}
}
]
}
},
{
"id":"7e730e6c-be56-4397-abcc-f58833441ce4",
"title":"這是用例名2",
"markers":[
{
"markerId":"priority-2"
}
],
"children":{
"attached":[
{
"id":"4a8b8fe8-ac98-4d14-abe6-8e522492a86a",
"title":"步驟1&結果1"
},
{
"id":"9f5c6a48-c4c2-45b8-b9e2-51df29015fb3",
"title":"步驟2&結果2"
},
{
"id":"2d53504f-e658-4060-8507-ed90b04a9419",
"title":"結果",
"titleUnedited":true
}
]
}
}
]
}
},
{
"id":"11988da4-2a01-4d2c-b8e6-4de49998779f",
"title":"模塊1-1",
"children":{
"attached":[
{
"id":"a7289a52-ac9f-48ba-a1ce-9fa86dd10010",
"title":"/模塊1-1用例沒有前置條件",
"markers":[
{
"markerId":"priority-1"
}
],
"children":{
"attached":[
{
"id":"c32ad9cc-f68e-4373-9b70-77dc92177a14",
"title":"步驟1",
"children":{
"attached":[
{
"id":"22136d6c-dc41-46f9-a601-8c1868eaed69",
"title":"結果1"
}
]
},
"titleUnedited":true
}
]
}
},
{
"id":"7aaaaeaf-103c-46dc-8163-b6ba069f61cb",
"title":"模塊1-1用例,沒有步驟和結果",
"markers":[
{
"markerId":"priority-3"
}
]
},
{
"id":"63574e0d-9597-42af-9f2c-3ad987682281",
"title":"模塊1-1用例只有結果",
"markers":[
{
"markerId":"priority-2"
}
],
"children":{
"attached":[
{
"id":"9e1c42ed-f948-41b5-b993-2e768f976625",
"title":"結果1"
},
{
"id":"05ec053e-77e5-4e6a-91f4-d5992a85e737",
"title":"結果1"
}
]
}
}
]
}
}
]
}
},
{
"id":"193b56735e689ae86a01d91513",
"title":"模塊2",
"children":{
"attached":[
{
"id":"0f6c8c6d-5bb5-4536-94ba-cdbedbca149e",
"title":"這是前置條件,前面需要加圖標",
"markers":[
{
"markerId":"task-start"
}
],
"children":{
"attached":[
{
"id":"637a8703-0633-45c9-83ff-ec49513c7e6e",
"title":"/模塊2用例1",
"markers":[
{
"markerId":"priority-2"
}
],
"children":{
"attached":[
{
"id":"a061a8f2-8d38-4213-9399-ea3913e25feb",
"title":"步驟1&結果1"
},
{
"id":"a8f06d8e-801d-4acd-9ae2-01b99e7fb63e",
"title":"步驟2&結果2"
}
]
}
}
]
},
"titleUnedited":true
}
]
}
}
]
},
"extensions":[
{
"content":[
{
"content":"2",
"name":"right-number"
}
],
"provider":"org.xmind.ui.map.unbalanced"
}
]
},
"theme":{
(此處省略展示具體樣式信息)
},
"topicPositioning":"fixed"
}
]
所以我們要做的就是解析這個json文件然后拿到相應節點的內容填充到相應的excel單元格當中,可以看出文本類容主要集中在title標簽中,xmind的json路徑比較深,沒有做標記的話不好區分,俗話說沒有規矩不成方圓,所以我們需要定義xmind用例的格式這樣才好去解析它。