1. Start nsxmlparser
To use nsxmlparser, you must first create it and set various attributes. The following methods are used:
Initwithcontentsofurl creates a parser through nsurl
InitwithdataCreate a parser through nsdata, for example, xmlpaser = [[nsxmlparse alloc] initwithdata: webdata];
SetdelegateDefine a delegate for the parser
ParseRun the parser
2. Act as delegate
The five most important methods:
//Element start character foundProcessing functions
(That is, the beginning of the report element and the attributes of the element)
Method 1.-(Void) parser :( nsxmlparser *) parser
Didstartelement:( Nsstring *) elementname
Namespaceuri :( nsstring *) namespaceuri
Qualifiedname :( nsstring *) QNAME
Attributes :( nsdictionary *) attributedict
Method 2 .//Processing tag contains content characters
(All or part of the report element)
-(Void) parser :( nsxmlparser *)Parser foundcharacters:( Nsstring *) String
Method 3. // discover elementsHandler Of The TerminatorTo save the data of each element Project (that is, the end mark of the report element)
-(Void) parser :( nsxmlparser *) parser
Didendelement:( Nsstring *) elementname
Namespaceuri :( nsstring *) namespaceuri
Qualifiedname :( nsstring *) QNAME
Method 4. // reportResolution end
-(Void)Parserdidenddocument:( Nsxmlparser *) parser
Method 5. // report unrecoverable parsing errors
-(Void) paser: parsererroccured