Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XMLString returns wrong result #21

Open
Lamerchun opened this issue Sep 17, 2014 · 1 comment
Open

XMLString returns wrong result #21

Lamerchun opened this issue Sep 17, 2014 · 1 comment

Comments

@Lamerchun
Copy link

dictionary {
 root: array {
  .... 100 items
 }
}

returns 12...

in XMLStringForNode if node is an array, subcalls of XMLStringForNode on each array element should be called with nodeName:nil.

if ([node isKindOfClass:[NSArray class]])
{
    NSMutableArray *nodes = [NSMutableArray arrayWithCapacity:[node count]];
    for (id individualNode in node)
    {
        [nodes addObject:[self XMLStringForNode:individualNode withNodeName:nil]];
    }
    return [nodes componentsJoinedByString:@"\n"];
}
...

and if nodeName is nil. result has to be without nodeName around.

if(nodeName)
{
    return [NSString stringWithFormat:@"<%1$@%2$@>%3$@</%1$@>", nodeName, attributeString, innerXML];
}
else
{
    return [NSString stringWithFormat:@"%@", innerXML];
}
...
@BadChoice
Copy link

I believe the array should be included inside a tag, so do something like this:

if ([node isKindOfClass:[NSArray class]])
{
    NSMutableArray *nodes = [NSMutableArray arrayWithCapacity:[node count]];
    for (id individualNode in node)
    {
        [nodes addObject:[self XMLStringForNode:individualNode withNodeName:nil]];
    }
    return [NSString stringWithFormat:@"<%@>%@</%@>",nodeName,[nodes componentsJoinedByString:@"\n"],nodeName];
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants