5 Replies Latest reply: Feb 11, 2013 12:57 AM by amiya.sahu
amiya.sahu Level 1 Level 1 (0 points)

Hi,

     How to parse the given below xml using NSXMLParser ? Please give me some idea ...

 

<?xml version="1.0" encoding="ISO-8859-1"?>

<protocol>

  <user name="Admin">

       <modality name="DEFAULT">

               <layout default="true">1x1</layout>   //Problem to parse this tag i.e 1x1 value

     </modality>

  </user>

</protocol>

 

 

Thanks


iPad 2, iOS 5.1
  • 1. Re: Problem with XML Parsing ?
    etresoft Level 7 Level 7 (24,270 points)

    XML parsing is pretty straightforward. Post what code you have tried and we can take it from there.

  • 2. Re: Problem with XML Parsing ?
    amiya.sahu Level 1 Level 1 (0 points)

    I am using the below method :

     

    - (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName

                   namespaceURI:(NSString *)namespaceURI

                   qualifiedName:(NSString *)qualifiedName

                   attributes:(NSDictionary *)attributeDict

    {

          if(![elementName isEqual:@"layout "]) 

              NSString * defaultValue= [attributeDict objectForKey:@"default"];

    }

    <layout default="true">1x1</layout>

     

    I am getting defaultValue is true . But along with this I need to parse the 1x1 also and I am not able to do it .

     



  • 3. Re: Problem with XML Parsing ?
    etresoft Level 7 Level 7 (24,270 points)

    You aren't going to find that in "didStartElement". You need to use "parser:foundCharacters:" to parse text nodes.

  • 4. Re: Problem with XML Parsing ?
    amiya.sahu Level 1 Level 1 (0 points)

    Thanks for your reply ...

     

    If I am using "parser:foundCharacters:" method i m not able to get the

    default="true"  . But I need both value i.e. 1x1 and default="true"

    I have used both the method also but it is not going to  "didStartElement" .

     

    How to read both value ?

  • 5. Re: Problem with XML Parsing ?
    amiya.sahu Level 1 Level 1 (0 points)

    Thanks.

    I got the Solution.