Permalink
Browse files

Adding simple category methods to print the XML in either "pretty" or…

… "compact" forms.
  • Loading branch information...
1 parent 5a689e0 commit 34ed84e6dfe8c210fe003bcfe2646f1274a0d566 @robbiehanson committed Nov 2, 2011
Showing with 19 additions and 0 deletions.
  1. +3 −0 KissXML/Additions/DDXMLElementAdditions.h
  2. +16 −0 KissXML/Additions/DDXMLElementAdditions.m
@@ -14,6 +14,9 @@
- (NSString *)xmlns;
- (void)setXmlns:(NSString *)ns;
+- (NSString *)prettyXMLString;
+- (NSString *)compactXMLString;
+
- (void)addAttributeWithName:(NSString *)name stringValue:(NSString *)string;
- (NSDictionary *)attributesAsDictionary;
@@ -87,6 +87,22 @@ - (void)setXmlns:(NSString *)ns
}
/**
+ * Shortcut to get a pretty (formatted) string representation of the element.
+**/
+- (NSString *)prettyXMLString
+{
+ return [self XMLStringWithOptions:(DDXMLNodePrettyPrint | DDXMLNodeCompactEmptyElement)];
+}
+
+/**
+ * Shortcut to get a compact string representation of the element.
+**/
+- (NSString *)compactXMLString
+{
+ return [self XMLStringWithOptions:DDXMLNodeCompactEmptyElement];
+}
+
+/**
* Shortcut to avoid having to manually create a DDXMLNode everytime.
**/
- (void)addAttributeWithName:(NSString *)name stringValue:(NSString *)string

2 comments on commit 34ed84e

Hello,

Is there a chance that you might add the NSXMLDocumentTidyXML function to your KissXML ???
I would really appreciate that...
Thanx anyway...
Cheers

Or any alternative for this method would be awesome too.

Please sign in to comment.