4

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 !

pnuts
  • 58,317
  • 11
  • 87
  • 139
manar
  • 151
  • 8

1 Answers1

7

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 =)

sabadow
  • 5,095
  • 3
  • 34
  • 51
manar
  • 151
  • 8