我想知道如何将变量中的文本添加到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/

10-13 01:37