GDataXML Record File with xmlns Namespace

I am using GDataXML and I am encountering some problems writing an XML file. I followed the Raywenderlich tutorial, but I need to add some namespaces.

for example after that:
[FooElement addChild: bar1Element];
[FooElement addChild: bar2Element];
[FooElement addChild: bar3Element];
[FooElement addChild: bar4Element];

I would like to do something like this:
[FooElement addNamespace: @ "xmlns =" ​​https: // foo / bar / "

to get this result in the file: <Foo xmlns = "https: // foo / bar /" <bar1> xxxx </ bar1> <bar2> xxxx </ bar2> <bar3> xxxx </ bar3> <bar4> xxxx < / bar4> </Foo>

thanks for the help!

+4
source share
1 answer

I found a solution:

GDataXMLElement *FooElement = [GDataXMLNode elementWithName:@"Foo"]; NSArray *namespaces = [[NSArray alloc] initWithObjects:[GDataXMLNode namespaceWithName:nil stringValue:@"https://foo/bar/"], nil]; [FooElement setNamespaces:namespaces]; 

Hope this helps =)

+7
source

All Articles