Permalink
Browse files

Merge pull request #3 from dkuhnke/master

attributeNames and CDATA
  • Loading branch information...
arashpayan committed Nov 14, 2012
2 parents bd72496 + 00d7553 commit 9b2569d720f3e3d960285440bf19737908963c8a
Showing with 12 additions and 3 deletions.
  1. +1 −1 APDocument.m
  2. +1 −0 APElement.h
  3. +10 −2 APElement.m
View
@@ -28,7 +28,7 @@
This class is used as the NSXMLParser delegate that's responsible for
building APDocuments.
*/
-@interface APXMLBuilder : NSObject
+@interface APXMLBuilder : NSObject <NSXMLParserDelegate>
{
APElement *rootElement;
APElement *openElement;
View
@@ -43,6 +43,7 @@
- (void)addChild:(APElement*)anElement;
- (void)appendValue:(NSString*)aValue;
- (int)attributeCount;
+- (NSArray *)attributeNames;
- (int)childCount;
- (NSArray*)childElements;
- (NSMutableArray*)childElements:(NSString*)aName;
View
@@ -109,6 +109,13 @@ - (int)attributeCount {
return [attributes count];
}
+/*
+ Returns the names of attributes on this element
+ */
+- (NSArray *)attributeNames {
+ return [attributes allKeys];
+}
+
/*
Returns the number of child elements
*/
@@ -270,7 +277,8 @@ - (NSString*)xml {
}
else // there must be a value
{
- [xmlResult appendFormat:@">%@</%@>", [self encodeEntities:value], name];
+ [xmlResult appendFormat:@"><![CDATA[%@]]></%@>", value, name];
+ //[xmlResult appendFormat:@">%@</%@>", [self encodeEntities:value], name];
return xmlResult;
}
}
@@ -281,7 +289,7 @@ - (NSString*)xml {
*/
- (NSString*)encodeEntities:(NSMutableString*)aString {
if (aString == nil || [aString length] == 0)
- return nil;
+ return @"";
NSMutableString *result = [[NSMutableString alloc] init];
[result appendString:aString];

0 comments on commit 9b2569d

Please sign in to comment.