How to parse Omnifocus XML data for details about a particular task?
<p>Considering that Omnifocus does not have an API, I've created a script that pulls Omnifocus Data which is in XML format on a recurring basis</p>

<p><a href="https://gist.githubusercontent.com/ChrismCruz/3612fdbe9f7baeef0c668113ca15fd17/raw/e6c8ca70bedc23456f499bca8dcc499a787f4018/gistfile1.txt" rel="nofollow">See linked here for the full omnifocus data set</a></p>

<p>I'm trying my best to parse this data set so that I can get these attributes for a task that is called "This is a test task"</p>

<p>I want to pull the following attributes from this task from that xml data</p>

<ul>
<li>Task Name: "This is a test task"</li>
<li>Completed Date: "10/02/2016"</li>
<li>Added Date: "10/02/2016"</li>
<li>Project: "Test Project"</li>
<li>Due Date: "10/11/2016"</li>
<li>Duration: 10 minutes</li>
</ul>

<p>See below for my python script: </p>

<pre><code>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: 
#&gt;&gt; e.g. &lt;task id="lyZY7EINc02" op="update"&gt;&lt;added&gt;2016-10-02T19:53:09.672Z&lt;/added&gt;&lt;modified&gt;2016-10-02T19:53:13.912Z&lt;/modified&gt;&lt;name&gt;This is a test task&lt;/name&gt;&lt;/task&gt;
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: 
#&gt;&gt; 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'}
</code></pre>

<p>Although, I can get the task_added date and the task_name, I can't get the other attributes I'm hoping to get. </p>

<p>You just need to use the <em>name</em> text to find the node then just call <em>.parent</em> to get the <em>task</em> node.</p>

<pre><code>In [55]: task
Out[55]: &lt;task id="lyZY7EINc02" op="update"&gt;&lt;added&gt;2016-10-02T19:53:09.672Z&lt;/added&gt;&lt;modified&gt;2016-10-02T19:53:13.912Z&lt;/modified&gt;&lt;name&gt;This is a test task&lt;/name&gt;&lt;/task&gt;
</code></pre>

python xml parsing beautifulsoup omnifocus