• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: XMLParser
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: XMLParser


  • Subject: Re: XMLParser
  • From: David Blanton <email@hidden>
  • Date: Sun, 29 Mar 2009 13:20:03 -0600

acolol way to  parse is make you element names method names



- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *) elementName namespaceURI:(NSString *)namespaceURI qualifiedName: (NSString *)qualifiedName attributes:(NSDictionary *)attributeDict {

	elementName = [elementName stringByAppendingString:@":"];
	SEL selector = NSSelectorFromString(elementName);
	if([self respondsToSelector:selector])
		[self performSelector:selector withObject:attributeDict];

}


Then an element parser looks like where 'properties'was an XML: element name


- (void)properties:(NSDictionary *)attributeDict {

	id obj = [attributeDict objectForKey:@"count"];
	// do more
}


On Mar 28, 2009, at 9:47 PM, Marcel Weiher wrote:


On Mar 23, 2009, at 20:13 , Dave Geering wrote:

On Tue, Mar 24, 2009 at 1:53 PM, Development
<email@hidden> wrote:
I'm using an an NSXMLParser to parse a document. some of the elements are as
follows: <element property="value">Some Thing</element>
The problem is that I cannot seem to come up with the element's property.
During the parse which callback is going to give me the property and it's
value?

Those are usually called attributes, not properties. Have a look at this delegate method:

parser:foundAttributeDeclarationWithName:forElement:type:defaultValue :

http://developer.apple.com/documentation/Cocoa/Reference/ Foundation/Classes/NSXMLParser_Class/Reference/Reference.html#// apple_ref/doc/uid/20001984-BBCCIFGB

That's for the declaration, if there is one, not for the actual attributes and values during the parse.


Marcel

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
40tularosa.net


This email sent to email@hidden



David Blanton





_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >XMLParser (From: Development <email@hidden>)
 >Re: XMLParser (From: Dave Geering <email@hidden>)
 >Re: XMLParser (From: Marcel Weiher <email@hidden>)

  • Prev by Date: Re: XMLParser
  • Next by Date: should release or not? (basic memory management question)
  • Previous by thread: Re: XMLParser
  • Next by thread: Re: XMLParser
  • Index(es):
    • Date
    • Thread