I'm trying to create a XML string which should contain solo tags (ie. tag without separate closing tags) I am able to create normal xml tags like
<tagname attribute=attributevalue></tagname>
using the code
NSXMLElement *childElement=[[NSXMLElement alloc] initWithName:childName];
childElement.stringValue=childValue;
[childElement addAttribute:[NSXMLNode attributeWithName:attributeName stringValue:attributeValue]];
[self.currentNode addChild:[childElement copy]];
but I need it like this
<tagname attributename=attributevalue />
and
are completely equivalent in XML and it is only a question of formatting how do you write them. If you don't have some particular reason to create "beautifully formatted" XML source code, I wouldn't bother myself with it.
Also, the code above does not create neither representation: it stores the data in an internal structure not if the form of XML source code. Your question might be valid only when you want to export the XML tree structure into a XML source file.