Permalink
Browse files

added new method to retrieve all attribute names; added cdata wrap

  • Loading branch information...
1 parent 9cf4a08 commit b0e80a7c2ca1cbde430bac3256b708d139409f0f @dkuhnke dkuhnke committed Nov 9, 2012
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
@@ -110,6 +110,13 @@ - (int)attributeCount {
}
/*
+ Returns the names of attributes on this element
+ */
+- (NSArray *)attributeNames {
+ return [attributes allKeys];
+}
+
+/*
Returns the number of child elements
*/
- (int)childCount {
@@ -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 b0e80a7

Please sign in to comment.