I am having trouble identifying the correct element in Python. What I actually want to see is the latest accessed file in the recently-used.xbel. Therefore I want to iterate over every file to find the one with the latest modified or latest visited This is how the XML file looks like.
<?xml version="1.0" encoding="UTF-8"?>
<xbel version="1.0"
xmlns:bookmark="http://www.freedesktop.org/standards/desktop-bookmarks"
xmlns:mime="http://www.freedesktop.org/standards/shared-mime-info"
>
<bookmark href="file:///tmp/google-chrome-stable_current_amd64.deb" added="2021-09-14T12:09:05Z" modified="2021-09-14T12:09:05Z" visited="2021-09-15T09:12:13Z">
<info>
<metadata owner="http://freedesktop.org">
<mime:mime-type type="application/vnd.debian.binary-package"/>
<bookmark:applications>
<bookmark:application name="Firefox" exec="'firefox %u'" modified="2021-09-14T12:09:05Z" count="1"/>
</bookmark:applications>
</metadata>
</info>
</bookmark>
<bookmark href="file:///home/test/Git/testprog" added="2021-09-15T09:12:13Z" modified="2021-09-15T09:12:13Z" visited="2021-09-15T09:12:13Z">
<info>
<metadata owner="http://freedesktop.org">
<mime:mime-type type="inode/directory"/>
<bookmark:applications>
<bookmark:application name="code" exec="'code %u'" modified="2021-09-15T09:12:13Z" count="1"/>
</bookmark:applications>
</metadata>
</info>
</bookmark>
<bookmark href="file:///home/test/.local/share/recently-used.xbel" added="2021-09-15T09:51:57Z" modified="2021-09-15T09:51:57Z" visited="2021-09-15T09:51:57Z">
<info>
<metadata owner="http://freedesktop.org">
<mime:mime-type type="application/x-xbel"/>
<bookmark:applications>
<bookmark:application name="code" exec="'code %u'" modified="2021-09-15T09:51:57Z" count="1"/>
</bookmark:applications>
</metadata>
</info>
</bookmark>
<bookmark href="file:///tmp/slack-desktop-4.19.2-amd64.deb" added="2021-09-15T11:45:49Z" modified="2021-09-15T11:45:49Z" visited="2021-09-16T13:26:26Z">
<info>
<metadata owner="http://freedesktop.org">
<mime:mime-type type="application/vnd.debian.binary-package"/>
<bookmark:applications>
<bookmark:application name="Firefox" exec="'firefox %u'" modified="2021-09-15T11:45:49Z" count="1"/>
</bookmark:applications>
</metadata>
</info>
</bookmark>
<bookmark href="file:///home/test/Downloads/google-chrome-stable_current_amd64.deb" added="2021-09-15T11:52:39Z" modified="2021-09-15T11:52:39Z" visited="2021-09-16T13:26:26Z">
<info>
<metadata owner="http://freedesktop.org">
<mime:mime-type type="application/vnd.debian.binary-package"/>
<bookmark:applications>
<bookmark:application name="Firefox" exec="'firefox %u'" modified="2021-09-15T11:52:39Z" count="1"/>
</bookmark:applications>
</metadata>
</info>
</bookmark>
<bookmark href="file:///home/test/Documents/libretest" added="2021-09-15T11:58:53Z" modified="2021-09-15T11:58:53Z" visited="2021-09-16T13:26:26Z">
<info>
<metadata owner="http://freedesktop.org">
<mime:mime-type type="application/octet-stream"/>
<bookmark:applications>
<bookmark:application name="LibreOffice 6.4" exec="'soffice %u'" modified="2021-09-15T11:58:53Z" count="1"/>
</bookmark:applications>
</metadata>
</info>
</bookmark>
<bookmark href="file:///home/test/Documents/libretest.odt" added="2021-09-15T11:58:53Z" modified="2021-09-15T15:42:04Z" visited="2021-09-16T13:26:26Z">
<info>
<metadata owner="http://freedesktop.org">
<mime:mime-type type="application/vnd.oasis.opendocument.text"/>
<bookmark:applications>
<bookmark:application name="LibreOffice 6.4" exec="'soffice %u'" modified="2021-09-15T15:42:04Z" count="12"/>
</bookmark:applications>
</metadata>
</info>
</bookmark>
<bookmark href="file:///home/test/Git/node-socket" added="2021-09-16T13:26:25Z" modified="2021-09-16T13:26:49Z" visited="2021-09-16T13:26:26Z">
<info>
<metadata owner="http://freedesktop.org">
<mime:mime-type type="inode/directory"/>
<bookmark:applications>
<bookmark:application name="code" exec="'code %u'" modified="2021-09-16T13:26:49Z" count="2"/>
</bookmark:applications>
</metadata>
</info>
</bookmark>
</xbel>
In my code I am trying to access bookmark:applications but with no success.
home = str(Path.home())
root = ET.parse(home + '/.local/share/recently-used.xbel').getroot()
print(root)
print('lower')
for bookmark in root.iter('bookmark'):
print(bookmark)
for applications in bookmark.find('applications'):
print(applications)
What would be the correct way to access bookmark:applications and find the last visited?
xmltodictbookmark:applicationselement is bound to thehttp://www.freedesktop.org/standards/desktop-bookmarksnamespace (by way ofxmlns:bookmark="http://www.freedesktop.org/standards/desktop-bookmarks"). See docs.python.org/3/library/…