【发布时间】:2011-08-13 10:54:21
【问题描述】:
问题:
从 .XSD 模板生成的 XML 文件产生粘贴在下面的输出。由于 category 的键是 image,因此我解析 image 项目的标准方法不适用于 category。我想将 category name="Category #" 放入一个数组中,如何从类别字段中创建一个数组。
我需要什么:
我想要的是一个字典数组。每个位置都包含一个代表一个类别的字典,每个字典都包含该类别的图像。
Array: @"Category 1",@"Category 2",@"Category 3";
For each Array, a Dictionary with: <image>以及介于两者之间的所有内容</image>基本上,我需要从 XML 数据源创建一个如下图所示的 plist
XML 输出:
<?xml version="1.0" encoding="UTF-8"?>
<app xmlns="http://www.wrightscs.com/_xml_.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.wrightscs.com/_xml_.xsd" name="Testing" unlock_product_id="com.wrightscs.all">
<bannerImg>http://www.wrightscs.com</bannerImg>
<category name="Category 1" icon="http://www.wrightscs.com">
<image>
<title>title</title>
<thumbUrl>http://www.wrightscs.com</thumbUrl>
<sampleUrl>http://www.wrightscs.com</sampleUrl>
<imageUrl>http://www.wrightscs.com</imageUrl>
<description>These items / keys not an issue.</description>
<infoUrl>http://www.wrightscs.com</infoUrl>
<license>http://www.wrightscs.com</license>
<licenseUrl>http://www.wrightscs.com</licenseUrl>
</image>
</category>
<category name="Category 2" icon="http://www.wrightscs.com">
<image>
<title>title</title>
<thumbUrl>http://www.wrightscs.com</thumbUrl>
<sampleUrl>http://www.wrightscs.com</sampleUrl>
<imageUrl>http://www.wrightscs.com</imageUrl>
<description>These items / keys not an issue.</description>
<infoUrl>http://www.wrightscs.com</infoUrl>
<license>http://www.wrightscs.com</license>
<licenseUrl>http://www.wrightscs.com</licenseUrl>
</image>
</category>
<category name="Category 3" icon="http://www.wrightscs.com">
<image>
<title>title</title>
<thumbUrl>http://www.wrightscs.com</thumbUrl>
<sampleUrl>http://www.wrightscs.com</sampleUrl>
<imageUrl>http://www.wrightscs.com</imageUrl>
<description>These items / keys not an issue.</description>
<infoUrl>http://www.wrightscs.com</infoUrl>
<license>http://www.wrightscs.com</license>
<licenseUrl>http://www.wrightscs.com</licenseUrl>
</image>
</category>
</app>
注意:其他项目/键都不是问题,我只对将类别制作成数组感兴趣。此示例中的 URL 也被替换为原始内容。
【问题讨论】:
-
你的标题表明你的问题已经得到解答,解决办法是什么?
-
感谢您在此处发布。它保持整洁。
标签: xml ios nsarray nsdictionary nsxmlparser