C.Johns
C.Johns

Reputation: 10245

objective c XMLWriter

I am wanting to know how to add text from a variable into an xml writer.

This is what I am trying to do below

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];

so pretty much how you do an nslog.. but i would like to know how i can do this with xmlwriter.. or if its even possible?

otherwise i guess the other option would be to create the whole string outside of the xmlwriter? what do you think?

Upvotes: 1

Views: 949

Answers (1)

sosborn
sosborn

Reputation: 14694

Try this:

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

Upvotes: 2

Related Questions