Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #3 from dkuhnke/master

attributeNames and CDATA
  • Loading branch information...
commit 9b2569d720f3e3d960285440bf19737908963c8a 2 parents bd72496 + 00d7553
@arashpayan authored
Showing with 12 additions and 3 deletions.
  1. +1 −1  APDocument.m
  2. +1 −0  APElement.h
  3. +10 −2 APElement.m
View
2  APDocument.m
@@ -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
1  APElement.h
@@ -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
12 APElement.m
@@ -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];
Please sign in to comment.
Something went wrong with that request. Please try again.