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