Search code examples
objective-ciosxmlcocoa-touchgdata

GDataXMLElement to raw xml string in ios


I would like to get the string representation of a GDataXMLElement, including the tag, attributes, and children. For example,

NSLog(@"%@", [e description]);

Will give below output

GDataXMLElement 0x5f26720: {type:1 name:to xml:"<to>Tove</to>"}

But I want to get

<to>Tove</to>

I know I can format the string with some code, but is there a better way to do this?


Solution

  • once you have the element you can extract the string from it using...

    NSLog(@"the values inside are %@",elementName.stringValue);
    

    you can refer this excellent tutorial by ray wenderlich..

    EDIT: if you want the complete XML as you stated in your comment you can use..

    NSLog(@"the values inside are %@",elementName.XMLString);