man*_*nar 4 namespaces xml-namespaces gdataxml
我正在使用GDataXML,我遇到了编写XML文件的一些问题.我按照Raywenderlich的教程,但我必须添加一些名称空间.
例如:
[FooElement addChild:bar1Element];
[FooElement addChild:bar2Element];
[FooElement addChild:bar3Element];
[FooElement addChild:bar4Element];
我想做类似的事情:
[FooElement addNamespace:@"xmlns ="https:// foo/bar /"
将此结果 存入文件:
<Foo xmlns ="https:// foo/bar /" >
<bar1> xxxx </ bar1>
<bar2> xxxx </ bar2>
<bar3> xxxx </ bar3>
<bar4> xxxx </ bar4>
</ Foo>
感谢帮助 !
我找到了解决方案:
GDataXMLElement *FooElement = [GDataXMLNode elementWithName:@"Foo"];
NSArray *namespaces = [[NSArray alloc]
initWithObjects:[GDataXMLNode namespaceWithName:nil
stringValue:@"https://foo/bar/"], nil];
[FooElement setNamespaces:namespaces];
Run Code Online (Sandbox Code Playgroud)
我希望这会有所帮助=)