如何解析以下字符串?

时间:2011-06-22 01:54:28

标签: iphone objective-c ios

我想获取Date,FirstName,LastName和签名值

<SignatureInfo Date="6/19/2011 4:13:19 PM" FirstName="Tony" LastName="Jarvis" Signature="mbbIVNZcZmB4EPlrWWDcSGGMKvZ3GVGERxNPnB2AvNRFqOCw4aDHNpeEQ2rB80SzYjpwf7Ur6iH1zjWSeAu2rTEwPfPx/hbIWAtbNKsX6M9AYUecpS1O2JdBfIUw4STkjGqWBsROQv3jr67CVR5ZWqYbGd1NNOQ60G5CV46CiRI=" xmlns="" />

1 个答案:

答案 0 :(得分:2)

很简单。只需运行NSXMLParser,然后查找命名空间元素。

例如,在didStartElement中,为您想要的每个元素执行类似的操作:

-(void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict { 
    NSString *firstName = [attributeDict objectForKey:@"FirstName"]];
}