On Mon, 15 Nov 2004 17:25:03 -0600, "Steve Mills" <email@hidden>
wrote:
> I've read the docs and I just don't understand. How can I take a .plist
> file, read and parse it, then iterate through each element? The .plist
> root is an array, each element in the array is a dictionary. Somewhere
> in the docs it illustrates how to use CFXMLTreeCreateFromData, but the
> resulting tree was nil. I'm totally confused about all the nodes and
> trees and property lists. Anybody have some sample source?
If all the XML items are CF objects (strings, arrays, properties, etc.) then
you can use:
// ---------------------------------
// load a property list from an XML file
CFPropertyListRef CreatePropertiesFromXMLFile(const CFURLRef pCFURLRef)
{
CFDataRef xmlCFDataRef;
CFPropertyListRef myCFPropertyListRef = NULL;
Boolean status;
// Read the XML file.
status = CFURLCreateDataAndPropertiesFromResource(
kCFAllocatorDefault, pCFURLRef,
&xmlCFDataRef, NULL, NULL, NULL);
if (status)
{
// Reconstitute the dictionary using the XML data.
myCFPropertyListRef = CFPropertyListCreateFromXMLData(
kCFAllocatorDefault, xmlCFDataRef,
kCFPropertyListImmutable, NULL);
// Release the XML data
CFRelease(xmlCFDataRef);
}
return myCFPropertyListRef;
}
This is from: <http://developer.apple.com/qa/qa2001/qa1208.html>.
--
Enjoy,
George Warner,
Schizophrenic Optimization Scientist
Apple Developer Technical Support (DTS)
As an extra service to our developers, we in Apple's Developer Technical
Support (DTS), are encouraging all of our developers to check out our cool
*NEW* web-sites for access to lots of new sample code and to see if any of
your questions have already been answered.
Sample code: <http://developer.apple.com/samplecode/index.html>
Reference Lib: <http://developer.apple.com/referencelibrary/index.html>
Mailing Lists: <http://www.lists.apple.com/>
Knowledge Base: <http://kbase.info.apple.com>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/carbon-dev/email@hidden
This email sent to email@hidden