我有一些包含BASE 64 ENCODED PNG 图像的 xml我正在尝试将其解析为某种类型的对象..暂时转换为NSArray
of NSDictionaries
,但是我目前没有成功。
这是我的解析委托的一部分:
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict
{
if([elementName isEqualToString:@"GUI"]){
parsedGUIMutableDictionary = [[NSMutableDictionary alloc] initWithDictionary:attributeDict];
}
}
- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
{
if ([elementName isEqualToString:@"GUI"]) {
[parsedDataArrayOfDictionaries addObject:parsedGUIMutableDictionary];
}
}
完成此操作后,字典中没有保存任何值,因此它只是空的...我在两个 if 语句中添加了一个断点,并且当输入第一个 if 语句时, attributeDict为空。
这是 xml 的样子:
<IC>
<Reps>
<GUI>iVBORw0KGgoAAAANSUhEUgAAAiwAAAFKCAMAAAF+68SXAAADAFBMVEUAAAAAADMAAGYAAJkAAMwA
AP8AMwAAMzMAM2YAM5kAM8wAM/8AZgAAZjMAZmYAZpkAZswAZv8AmQAAmTMAmWYAmZkAmcwAmf8A
zAAAzDMAzGYAzJkAzMwAzP8A/wAA/zMA/2YA/5kA/8wA//8zAAAzADMzAGYzAJkzAMwzAP8zMwAz
MzMzM2YzM5kzM8wzM/8zZgAzZjMzZmYzZpkzZswzZv8zmQAzmTMzmWYzmZkzmcwzmf8zzAAzzDMz
zGYzzJkzzMwzzP8z/wAz/zMz/2Yz/5kz/8wz//9mAABmADNmAGZmAJlmAMxmAP9mMwBmMzNmM2Zm
M5lmM8xmM/9mZgBmZjNmZmZmZplmZsxmZv9mmQBmmTNmmWZmmZlmmcxmmf9mzABmzDNmzGZmzJlm
zMxmzP9m/wBm/zNm/2Zm/5lm/8xm//+ZAACZADOZAGaZAJmZAMyZAP+ZMwCZMzOZM2aZM5mZM8yZ
M/+ZZgCZZjOZZmaZZ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IhFkl2sVieiryN+wxjiUJ+sWCLIs7hLrFIiEVCLBJikWQdS7iI8o4l
0N8szXC+hVgkvIgkxCIhFgmxSIhFQiyS9ljsQsp8YsHgD+7MZxpK3y5qbBG3bSEWCbFIiEVCLBJi
kcwzlpGrhOY630IsYSAWCbFIiEVCLBJikcw9Fq/lMPOfWFj8NFRbc2zpaT4AYpEQi4RYJMQiWVIs
AyJaVCyuq4TmP99CLBbN/0IsEmKREIuEWCTEIlluLB0PXtbEwoDFU//ZFNtLarF0Lp5ari09EIuE
WCTEIiEWCbFIiKW4XSXEfMvxG8TiBrFIiEVCLBJikRCLhFgkxCIhFgmxSIhFQiyS7GKJA7FIiEVC
LBJikRCLhFgkxCIhFgmxSIhFQiwSYpEQi4RYJMQiIRYJsUiIRTImlvWv9fX1Wl8vKpZi7Xxd3H2f
+Pra/UuV7+ixPJ+oqpeX58blZX359aSX57J8GxTLXfM5+sRyftBb+Sk6SYb38k8xRSxFsSnfG338
SiyXYvM0TSx7Y/6xLpNjM1Est50kwyGXd2K54ugLsVxBLBJikRCLhFgkxCIZGUtdEEtLLEXjTmI5
QCx7OmIpGt8ilqsGxNIBsUiIpQNikRBLB8QiIZYOiEWyhFj8IZaBj7+IZVvv2U5IkrGUZbW7lJuJ
</GUI>
</Reps>
</IC>
我希望有人知道如何帮助我从这个 XML 中获取数据,这样我就可以使用类似于下面的代码来解码我的 png
[Base64 initialize];
NSData *data = [Base64 decode:img];
cell.image.image = [UIImage imageWithData:data];
任何帮助将不胜感激。