English 中文(简体)
NSXMLParser: 储存价值在哪里?
原标题:NSXMLParser : where store values?

我想,我的手稿将使用XML,作为某种先验者。 我想分析xml文档,然后抽取屏幕。 例如,在构造中,有Xml文档:

<app>
   <screens>        
    <screen name="myscreen1">
            <font fontsize="32" fontcolor="#000000" fontface="font.ttf"/>

            <button tmpl="bk"/>

            <list area="0px 74px 100% 100%">
                <item tmpl="myitem1" target="myitemelsewhere">
                    <image tmpl="myitem1" img="myimg1.png"/>
                    <text tmpl="myitem1">Test</text>
                </item>
                <item tmpl="myitem2" target="myitemelsewhere">
                    <image tmpl="myitem2" img="myimg2.png"/>
                    <text tmpl="myitem2">Test</text>
                </item>
             </list>
    </screen>
<!--screen 2 the same way -->
</screens>
</app>

I 执行NSXMLparser, i 简单可读为属性和标签。 问题。 我的问题是。 当我拿到第一个要素(摘自我的屏幕1)时,什么是把它放在哪里的最佳想法,什么时候 gr掉所有屏幕上的声明标签和属性? NSSet? ? NSArray? 例如:

- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict 
{
    element = [NSMutableString string];

    if([elementName isEqualToString:@"screen"])
    {
        //What should i do here to tell my app to store all attributes? Where to put this?
    }
}
最佳回答

通常有变数来保存数据,这些数据正在流出,可以变数储存正在处理的XML标记。 你的上述位置是确定你目前正在处理的XML标记。 这里有一条伟大的榜样,使你们开始:

http://weblog.bignerdranch.com/?p=48

问题回答

暂无回答




相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...

热门标签