tags:

views:

35

answers:

1

Hi,

I am working on an iphone application in which I am consuming a webservice. So i am parsing the XML file data. any idea about how to parse self closing tag like: State/ and how to read data of self tag like: Contact Email="[email protected]" Name="PhD" Phone="123-521-3388" Source="location"/

I am parsing xml file using NSXMLPARSER class methods and library

Thanks,

+1  A: 

Your sample XML data

<Contact Email="[email protected]" Name="PhD" Phone="123-521-3388" Source="location"/>

is equivalent to

<Contact Email="[email protected]" Name="PhD" Phone="123-521-3388" Source="location"></Contact>

and should be parsed by any XML parser.

Harold L
<Contact Email="[email protected]" Name="PhD" Phone="123-521-3388" Source="location"/>is this equivalent or not to<Contact Email="[email protected]" Name="PhD" Phone="123-521-3388" Source="location"></Contact>first one is self closing tag,when i parse this i got a string like "\n ".so how can i read EMAIL, NAME PHONE ??
Email, Name, Phone and Source are XML "attributes". To use the Mac OS NSXMLParser class to get attributes, you need to give the NSXMLParser an NSXMLParserDelegate that looks at the attributes passed to the [parser:didStartElement:namespaceURI:qualifiedName:attributes:](http://developer.apple.com/mac/library/documentation/cocoa/reference/NSXMLParserDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intfm/NSXMLParserDelegate/parser:didStartElement:namespaceURI:qualifiedName:attributes:) method.
Harold L
By the way, the attributes passed to that method are an NSDictionary, see [the NSDictionary discussion here.](http://developer.apple.com/mac/library/documentation/cocoa/conceptual/Collections/Articles/Dictionaries.html)
Harold L