4
votes

I'm using GDataXML and I encounter some problems to write a XML file. I followed Raywenderlich's tutorial but i have to add some namespaces.

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

i would like to do something like that:
[FooElement addNamespace:@"xmlns="https://foo/bar/"

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

thanks for help !

1

1 Answers

7
votes

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

I hope this will help =)