[IOS] XML Parsing

Source: Internet
Author: User
Tags radar

 

1. Related Classes

Main parsing classes:

@ Interface nsxmlparser: nsobject {

}

-(ID) initwithcontentsofurl :( nsurl *) URL;

// Initialize the URL specified by the parser.

-(ID) initwithdata :( nsdata *) data;

// Create a parser from data


-(ID) initwithstream :( nsinputstream *) stream ns_available (10_7, 5_0 );

// Create a parser to incrementally extract data from the specified stream and parse it.

// Delegate management. The delegate is not retained.


-(ID <nsxmlparserdelegate>) delegate;


-(Void) setdelegate :( id <nsxmlparserdelegate>) delegate;

-(Void) setshouldprocessnamespaces :( bool) shouldprocessnamespaces;
-(Void) setshouldreportnamespaceprefixes :( bool) shouldreportnamespaceprefixes;
-(Void) setshouldresolveexternalentities: (bool) shouldresolveexternalentities;

-(Bool) shouldprocessnamespaces;


-(Bool) shouldreportnamespaceprefixes;


-(Bool) shouldresolveexternalentities;

-(Bool) Parse;

// Call to start event-driven parsing. If yes is returned for a successful resolution, it is "no" in the case of an error ".

-(Void) abortparsing;

// Call the delegate to stop parsing. The delegate will receive an error message sent to it.

-(Nserror *) parsererror;

// The status of the parser after resolution.
@ End

Retrieve the classes in the resolution process:

// Once the resolution has started, the status of the delegate may be of interest to some parsers. During the analysis, these methods only return meaningful information or an error occurs later.

@ Interface nsxmlparser (nsxmlparserlocatoradditions)
-(Nsstring *) publicid;
-(Nsstring *) systemid;
-(Nsinteger) linenumber;
-(Nsinteger) columnnumber;
@ End

Callback interface for resolution:

// The parser indicates that the notification event passed in the nsxmlparserdelegateeventadditions class. @ Protocol nsxmlparserdelegate <nsobject>
@ Optional

// Document handling methods
-(Void) parserdidstartdocument :( nsxmlparser *) parser;
// The parser sends a message at the beginning of parsing the document.

-(Void) parserdidenddocument :( nsxmlparser *) parser;
// When the parser has completed parsing. If this happens, the resolution is successful.

// Various statements of the DTD processing method.


-(Void) parser :( nsxmlparser *) parser foundnotationdeclarationwithname :( nsstring *) Name publicid :( nsstring *) publicid systemid :( nsstring *) systemid;


-(Void) parser :( nsxmlparser *) parser foundunparsedentitydeclarationwithname :( nsstring *) Name publicid :( nsstring *) publicid systemid :( nsstring *) systemid notationname :( nsstring *) notationname;


-(Void) parser :( nsxmlparser *) parser foundattributedeclarationwithname :( nsstring *) attributename forelement :( nsstring *) elementname type :( nsstring *) type defaultvalue :( nsstring *) defaultvalue;


-(Void) parser :( nsxmlparser *) parser foundelementdeclarationwithname :( nsstring *) elementname model :( nsstring *) model;


-(Void) parser :( nsxmlparser *) parser foundinternalentitydeclarationwithname :( nsstring *) NAME value :( nsstring *) value;


-(Void) parser :( nsxmlparser *) parser foundexternalentitydeclarationwithname :( nsstring *) Name publicid :( nsstring *) publicid systemid :( nsstring *) systemid;


-(Void) parser :( nsxmlparser *) parser didstartelement :( nsstring *) elementname namespaceuri :( nsstring *) namespaceuri qualifiedname :( nsstring *) QNAME attributes :( nsdictionary *) attributedict;

// When the parser finds that the element begins to mark sending.

// In the case of the cvslog mark, the following is the delegate receipt:

// Elementname = cvslog, namespaceuri = http://xml.apple.com/cvslog, qualifiedname = cvslog


// In the case of radar flag, it is passed in the following:
// Elementname = radar, namespaceuri = http://xml.apple.com/radar, qualifiedname = radar: Radar


// If namespace processing> isn' t <on, the xmlns: Radar = "http://xml.apple.com/radar" is returned as an attribute pair, the elementname is 'radar: radar 'and there is no qualifiedname.


-(Void) parser :( nsxmlparser *) parser didendelement :( nsstring *) elementname namespaceuri :( nsstring *) namespaceuri qualifiedname :( nsstring *) QNAME;
// An end flag is encountered during sending. Parameters are provided as above.

-(Void) parser :( nsxmlparser *) parser didstartmappingprefix :( nsstring *) prefix touri :( nsstring *) namespaceuri;
// Send, when the parser first sees a namespace attribute.
// In the case of the cvslog tag, before the didstartelement:, you 'd get one of these with prefix = @ "" And namespaceuri = @ "http://xml.apple.com/cvslog" (I. e. the default namespace)
// In the case of the radar: Radar tag, before the didstartelement: you 'd get one of these with prefix = @ "radar" and namespaceuri = @ "http://xml.apple.com/radar"
-(Void) parser :( nsxmlparser *) parser didendmappingprefix :( nsstring *) prefix;
// The error message returned when the namespace prefix is out of the valid range.

-(Void) parser :( nsxmlparser *) parser foundcharacters :( nsstring *) string;
// Returns the character string encountered so far. You may not be able to get the longest running character. The parser reserves the right to delegate many of the potential requirements in the continuous

-Parser: foundcharacters:


-(Void) parser :( nsxmlparser *) parser foundignorablewhitespace :( nsstring *) whitespacestring;


// The Blank Space ignored by the parser report. It is found to be characters in the same way.

-(Void) parser :( nsxmlparser *) parser foundprocessinginstructionwithtarget :( nsstring *) Target Data :( nsstring *) data;


// The parser reports that you use this method to process commands.

In the case abve, target = @ "XML-stylesheet" and Data = @ "type = 'text/CSS 'href+'cvslog.css '"


-(Void) parser :( nsxmlparser *) parser foundcomment :( nsstring *) comment;
// Report comments (text in a <! --> Block) as a single string.


-(Void) parser :( nsxmlparser *) parser foundcdata :( nsdata *) cdatablock;
// Delegate the CDATA block in this report as an nsdata.


-(Nsdata *) parser :( nsxmlparser *) parser resolveexternalentityname :( nsstring *) Name systemid :( nsstring *) systemid;
// This gives an opportunity to solve the data and replies received by external entities.

-(Void) parser :( nsxmlparser *) parser parseerroccurred :( nserror *) parseerror;


// This report delegates a fatal error. The parser stops parsing.
-(Void) parser :( nsxmlparser *) parser validationerroccurred :( nserror *) validationerror;
// This report delegates a fatal error. The parser stops parsing.

@ End

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.