#import <Foundation/Foundation.h>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wobjc-missing-property-synthesis"
typedef NS_ENUM(NSInteger, XMLDictionaryAttributesMode)
{
XMLDictionaryAttributesModePrefixed = 0, //default
XMLDictionaryAttributesModeDictionary,
XMLDictionaryAttributesModeUnprefixed,
XMLDictionaryAttributesModeDiscard
};
typedef NS_ENUM(NSInteger, XMLDictionaryNodeNameMode)
{
XMLDictionaryNodeNameModeRootOnly = 0, //default
XMLDictionaryNodeNameModeAlways,
XMLDictionaryNodeNameModeNever
};
static NSString *const XMLDictionaryAttributesKey = @"__attributes";
static NSString *const XMLDictionaryCommentsKey = @"__comments";
static NSString *const XMLDictionaryTextKey = @"__text";
static NSString *const XMLDictionaryNodeNameKey = @"__name";
static NSString *const XMLDictionaryAttributePrefix = @"_";
@interface XMLDictionaryParser : NSObject <NSCopying>
+ (XMLDictionaryParser *)sharedInstance;
@property (nonatomic, assign) BOOL collapseTextNodes; // defaults to YES
@property (nonatomic, assign) BOOL stripEmptyNodes; // defaults to YES
@property (nonatomic, assign) BOOL trimWhiteSpace; // defaults to YES
@property (nonatomic, assign) BOOL alwaysUseArrays; // defaults to NO
@property (nonatomic, assign) BOOL preserveComments; // defaults to NO
@property (nonatomic, assign) BOOL wrapRootNode; // defaults to NO
@property (nonatomic, assign) XMLDictionaryAttributesMode attributesMode;
@property (nonatomic, assign) XMLDictionaryNodeNameMode nodeNameMode;
- (NSDictionary *)dictionaryWithParser:(NSXMLParser *)parser;
- (NSDictionary *)dictionaryWithData:(NSData *)data;
- (NSDictionary *)dictionaryWithString:(NSString *)string;
- (NSDictionary *)dictionaryWithFile:(NSString *)path;
@end
@interface NSDictionary (XMLDictionary)
+ (NSDictionary *)dictionaryWithXMLParser:(NSXMLParser *)parser;
+ (NSDictionary *)dictionaryWithXMLData:(NSData *)data;
+ (NSDictionary *)dictionaryWithXMLString:(NSString *)string;
+ (NSDictionary *)dictionaryWithXMLFile:(NSString *)path;
- (NSDictionary *)attributes;
- (NSDictionary *)childNodes;
- (NSArray *)comments;
- (NSString *)nodeName;
- (NSString *)innerText;
- (NSString *)innerXML;
- (NSString *)XMLString;
- (NSArray *)arrayValueForKeyPath:(NSString *)keyPath;
- (NSString *)stringValueForKeyPath:(NSString *)keyPath;
- (NSDictionary *)dictionaryValueForKeyPath:(NSString *)keyPath;
@end
@interface NSString (XMLDictionary)
- (NSString *)XMLEncodedString;
@end
#pragma GCC diagnostic pop
XML 格式转JSON 格式
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- /*! @brief 把格式化的JSON格式的字符串转换成字典 @param jsonString JSON格式的...
- /*! * @brief 把格式化的JSON格式的字符串转换成字典 * @param jsonString JSO...
- /*! * @brief 把格式化的JSON格式的字符串转换成字典 * @param jsonString JSO...
- json格式字符串转字典不能直接转化需要先转换成Data,在转化成字,同样字典也不能直接转换成json格式字符串。...