iphone - objective-c XMLWriter

标签 iphone ios xmlwriter

我想知道如何将变量中的文本添加到 xml 编写器中。

这就是我下面要做的

NSString *testString = [[NSString alloc] initWithString:@"TEST TEST TEST"];
    //allocate serializer
        id <XMLStreamWriter> xmlWriter = [[XMLWriter alloc] init];
        //add root element
        [xmlWriter writeStartElement:@"Rows"];
            [xmlWriter writeStartElement:@"Row"];
                [xmlWriter writeCharacters:@"request: %@ can go in here", testString]; //this line here
            [xmlWriter writeEndElement];
        //close rows element
        [xmlWriter writeEndElement];

你是怎么做 nslog 的。但我想知道我如何用 xmlwriter 做到这一点。或者它是否可能?

否则我想另一个选择是在 xmlwriter 之外创建整个字符串?你怎么看?

最佳答案

试试这个:

[xmlWriter writeCharacters:[NSString stringWithFormat:@"request: %@ can go in here", testString]]; //this line here

关于iphone - objective-c XMLWriter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9611319/

相关文章:

iphone - 当应用程序在后台或设备被锁定时运行代码

iphone - 简单的节拍器

ios - sysCall(Sys_gettid) 返回 -1

ios - 导航 Controller 和状态栏问题

c# - 在 C# 中从 XML Writer 创建 XML 元素对象

c# - 复制 xml 文件并在特定位置插入新元素 - C#

ios - iOS 上的 Flurry/Google Analytics/Localytics 带宽消耗

iphone - 禁用 iPhone 3G S 中的自动对焦功能

ios - 如何本地化全局字符串?

c# - 从 XML 读取/写入枚举