[Pythonmac-SIG] convert binary plist to xml string

Florian Munz surf at theflow.de
Mon May 9 00:40:59 CEST 2005


Nicholas Riley <njriley at uiuc.edu> wrote:

> In [3]: plist, format, error =
>NSPropertyListSerialization.propertyListFromData_mutabilityOption_forma
>t_errorDescription_(NSData.dataWithContentsOfMappedFile_(os.path.expand
>user('~/Library/Preferences/com.apple.keychainsync.plist')),
>NSPropertyListImmutable, 0)
> 
> In [4]: plist Out[4]: {KeychainSyncList = (); }
> 
> In [5]: data, error =
> NSPropertyListSerialization.dataFromPropertyList_format_errorDescription_(
> plist, NSPropertyListXMLFormat_v1_0)
>
> [...]

thanks, that works exactly the way I need it. I found out you can get
the string faster if you convert the NSData right away:

s = NSString.alloc().initWithData_encoding_(data, NSUTF8StringEncoding)


Florian



More information about the Pythonmac-SIG mailing list