• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            逛奔的蝸牛

            我不聰明,但我會很努力

               ::  :: 新隨筆 ::  ::  :: 管理 ::

            There's a class called NSXMLParser. It's used to parse XML files. However, NSXMLParser is stupid. All it knows how to do is parse XML, but it doesn't know what it's supposed to do with the information it finds.

            Enter a delegate. A delegate is like a nanny. Since the XMLParser doesn't have a clue what to do with the information it finds, it goes and asks its delegate about each and every thing: "Hey! I started parsing a document! Am I supposed to do anything?" "Hey! I found some CDATA! What am I supposed to do with it!" "Hey! I found another tag!" "Hey! I found a closing tag!", and so on. All of these "Hey!" statements are delegate methods, or in other words, they are optional methods that a delegate object may choose to implement. Usually (but not always), the object that creates the NSXMLParser is also the delegate, but that doesn't have to be the case.

            So you might have something like this:

            NSXMLParser * parser = [[NSXMLParser alloc] initWithContentsOfURL:someURLToAnXMLFile];
            [parser setDelegate:self];
            [parser parse];
            [parser release];

            Then in that same object (self), you might have some of these methods:

            - (void)parserDidStartDocument:(NSXMLParser *)parser {
             
            //the parser started this document. what are you going to do?
            }

            - (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName attributes:(NSDictionary *)attributeDict {
             
            //the parser found an XML tag and is giving you some information about it
             
            //what are you going to do?
            }

            - (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string {
             
            //the parser found some characters inbetween an opening and closing tag
             
            //what are you going to do?
            }

            - (void)parserDidEndDocument:(NSXMLParser *)parser {
             
            //the parser finished. what are you going to do?
            }

            There are a whole bunch of these methods listed in the documentation. Simply go to the NSXMLParser class reference, and they're all listed under the "Delegate Methods" section. Once you get the hang of it, NSXMLParser is pretty easy to use. It is a SAX Parser, which means it's event-driven parser. It finds stuff, and it tells you about it.


            From: http://stackoverflow.com/questions/1089737/parsing-xml-in-cocoa

            @import url(http://www.shnenglu.com/CuteSoft_Client/CuteEditor/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);
            posted on 2011-12-18 17:57 逛奔的蝸牛 閱讀(789) 評論(0)  編輯 收藏 引用 所屬分類: Cocoa
            久久综合亚洲色HEZYO国产| 久久久久久亚洲精品不卡 | 国产精品久久毛片完整版| 久久久久亚洲av无码专区喷水| 一级做a爰片久久毛片16| 国产亚洲精午夜久久久久久| 亚洲国产成人久久一区WWW| 亚洲中文字幕无码一久久区| 99精品久久精品一区二区| 亚洲Av无码国产情品久久| 狠狠88综合久久久久综合网 | 精品一久久香蕉国产线看播放| 亚洲精品tv久久久久久久久久| 精品久久久久久亚洲| 色综合久久久久综合99| 2020久久精品国产免费| 性做久久久久久免费观看| 国产午夜福利精品久久2021| 久久亚洲中文字幕精品一区| 久久久无码精品亚洲日韩按摩| 性高湖久久久久久久久AAAAA| 亚洲成色999久久网站| 久久66热人妻偷产精品9| 久久久国产视频| 久久精品国产99久久香蕉| 精品亚洲综合久久中文字幕| 精产国品久久一二三产区区别| 人人狠狠综合久久亚洲88| 99国产欧美久久久精品蜜芽 | 国产成人久久777777| 无码人妻久久久一区二区三区| 久久这里只有精品视频99| 精品久久香蕉国产线看观看亚洲| 日韩精品久久久肉伦网站| 久久香综合精品久久伊人| 久久一区二区三区99| 日本亚洲色大成网站WWW久久| 国产一区二区精品久久岳| 国产精品美女久久久久AV福利| 91精品观看91久久久久久| 久久久久久狠狠丁香|