Skip to content

Commit

Permalink
CDATA + Attributes tag.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Feb 12, 2016
1 parent 507b9f9 commit 192adfd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions SWXMLTags.h
Expand Up @@ -27,5 +27,7 @@
+ (NSString*) formatAttributes: (NSDictionary*)attributes;

+ (NSString*) tagNamed: (NSString*)name forValue: (NSString*)value withAttributes: (NSDictionary*)attributes;
+ (NSString*) tagNamed: (NSString*)name forCDATA: (NSString*)value withAttributes: (NSDictionary*)attributes;


@end
8 changes: 8 additions & 0 deletions SWXMLTags.m
Expand Up @@ -79,6 +79,14 @@ + (NSString*) tagNamed: (NSString*)name forValue: (NSString*)value withAttribute
return [NSString stringWithFormat:@"<%@%@>\n%@</%@>", name, [self formatAttributes:attributes], [self indent:value], name];
}

+ (NSString*) tagNamed: (NSString*)name forCDATA: (NSString*)value withAttributes: (NSDictionary*)attributes {
if (value == nil) value = @"";

NSString * inner = [self encodeBasicXMLEntities:value];

return [NSString stringWithFormat:@"<%@%@>%@</%@>", name, [self formatAttributes:attributes], inner, name];
}

+ (NSString*) tagNamed: (NSString*)name withAttributes: (NSDictionary*)attributes {
return [NSString stringWithFormat:@"<%@%@ />", name, [self formatAttributes:attributes]];
}
Expand Down

0 comments on commit 192adfd

Please sign in to comment.