Python Forum
plistlib / xml file / get value except key
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
plistlib / xml file / get value except key
#1
Hello Community,

I have transformed my bookmarks plist file to an XML file. I try to write a script where I am able to read the XML file, getting the URL information and generate a SQLite3 file with it.

I checked the Python 3 documentation about plistlib. I tried the following

import plistlib

fileName = "Bookmarks_example.xml"
print ("File: ", fileName)
print (" ")

with open(fileName, 'rb') as fp:
    pl = plistlib.load(fp)
print(pl["Children"])
When I try something else except Children I got a key error message

Error:
python3 helper_plist-xml_2.py File: Bookmarks_example.xml Traceback (most recent call last): File "/home/wchris/Python/helper_plist-xml_2.py", line 9, in <module> print(pl["string"]) KeyError: 'string'
Is it only possible to access key values?

How can I get the values from <string> so I can get the URL information?

I have add an example XML file

Best regards

--Christian

Attached Files

.xml   Bookmarks_example.xml (Size: 25.84 KB / Downloads: 346)
Reply


Messages In This Thread
plistlib / xml file / get value except key - by Tecuma - May-26-2021, 11:03 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Accessing nested dictionary values. Plistlib, Python 2.7 williamlombard 32 21,324 Sep-29-2017, 06:46 AM
Last Post: williamlombard

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020