Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 将plist对象转换为嵌入NSString中的XML_Ios_Xml_Text_Nsstring_Plist - Fatal编程技术网

Ios 将plist对象转换为嵌入NSString中的XML

Ios 将plist对象转换为嵌入NSString中的XML,ios,xml,text,nsstring,plist,Ios,Xml,Text,Nsstring,Plist,我想通过电子邮件以XML测试格式发送plist对象 在此之后,我应该编写什么样的代码(最好是简单的): NSString *xmlString; NSDictionary *borrowed = @{@"Reader": @"Ryan Shaw", @"Books": @[ @{@"Title": @"The Godfather", @"Author":

我想通过电子邮件以XML测试格式发送plist对象

在此之后,我应该编写什么样的代码(最好是简单的):

NSString *xmlString;
NSDictionary *borrowed = @{@"Reader": @"Ryan Shaw",
                           @"Books":  @[ @{@"Title":  @"The Godfather",
                                           @"Author": @"Mario Puzo",
                                           @"Date":   @"2014-04-08T13:36:33Z"},
                                         @{@"Title":  @"Adventures of Huckleberry Finn",
                                           @"Author": @"Mark Twain",
                                           @"Date":   @"2014-04-08T13:36:33Z"} ]
                         };
要使结果xmlString包含以下值:

@"<dict>
    <key>Reader</key>
    <string>Ryan Shaw</string>
    <key>Books</key>
    <array>
        <dict>
            <key>Title</key>
            <string>The Godfather</string>
            <key>Author</key>
            <string>Mario Puzo</string>
            <key>Date</key>
            <date>2014-04-08T13:36:33Z</date>
        </dict>
        <dict>
            <key>Title</key>
            <string>Adventures of Huckleberry Finn</string>
            <key>Author</key>
            <string>Mark Twain</string>
            <key>Date</key>
            <date>2014-04-08T13:36:33Z</date>
        </dict>
    </array>
</dict>"
@”
读者
瑞恩·肖
书
标题
教父
著者
马里奥·普佐
日期
2014-04-08T13:36:33Z
标题
哈克贝利·费恩历险记
著者
马克·吐温
日期
2014-04-08T13:36:33Z
"

是否有任何iOS框架能够做到这一点,或者我应该自己编写解析器还是使用第三方库?

缺少的代码如下:

    NSError *error;
    NSData *xmlData = [NSPropertyListSerialization dataWithPropertyList:borrowed
                                                                 format:NSPropertyListXMLFormat_v1_0
                                                                options:0
                                                                  error:&error];
    if ( !error )
        xmlString = [[NSString alloc] initWithData:xmlData encoding:NSUTF8StringEncoding];
没有必要将任何特殊的框架连接起来