- (re)indent an XML file
[permalink]
% setenv XMLLINT_INDENT " "
% xmllint --format oopack.xml > blah.xml
- Reading property lists from XML
[permalink]
This will read property lists in XML (or any of the other property list formats:)
NSData *data = // get NSData from somewhere, like NSFileManager
if (data) {
myRootObject = [NSPropertyListSerialization
propertyListFromData: data
mutabilityOption: NSPropertyListMutableContainers
format: nil
errorDescription: nil];
}
For the mutability options of the resulting object, you can also use NSPropertyListImmutable and NSPropertyListMutableContainersAndLeaves - Saving property lists as XML
[permalink]
You can save any of the "property list" classes (NSDictionary, NSArray,NSNumber, NSString, NSData) as XML like this:
NSData *data;
data = [NSPropertyListSerialization
dataFromPropertyList: notes
format: NSPropertyListXMLFormat_v1_0
errorDescription: nil];
Then write out the data using NSFileManager, or whatever other mechanism you wish.