考虑到Omnifocus没有API,我已经创建了一个脚本,用于反复提取XML格式的Omnifocus数据
See linked here for the full omnifocus data set
我正在尽力解析这个数据集,以便能够为一个名为“这是一个测试任务”的任务获取这些属性
我想从这个任务中从xml数据中提取以下属性
下面是我的python脚本:
from bs4 import BeautifulSoup
text_data = BeautifulSoup(xml_data_set)
list_of_tags = s.find_all(tag.has_attr('id'))
#This creates an array of strings. The string that I'm interested looks like the following:
#>> e.g. <task id="lyZY7EINc02" op="update"><added>2016-10-02T19:53:09.672Z</added><modified>2016-10-02T19:53:13.912Z</modified><name>This is a test task</name></task>
list_of_dicts = [loads(dumps(xmltodict.parse(str(i)))) for i in l]
#I then use xmltodict to change each tag into an a dictionary. The tag that I'm interested looks like the following:
#>> e.g. {'task_@id': 'lyZY7EINc02', 'task_modified': '2016-10-02T19:53:13.912Z', 'task_added': '2016-10-02T19:53:09.672Z', 'task_name': 'This is a test task', 'task_@op': 'update'}
虽然,我可以得到任务添加日期和任务名称,但我无法获得我希望获得的其他属性。在
您只需要使用名称文本来查找节点,然后调用.parent来获取任务节点。在
相关问题 更多 >
编程相关推荐