how to get a name of tag in XML

Discussion in 'iOS Programming' started by tranvutuan, Dec 31, 2011.

  1. tranvutuan macrumors member

    Joined:
    Dec 19, 2011
    #1
    Given a sample.xml like below

    Code:
    <myXML>
       <item1>   this is my item1   </item1>
       <item2>   this is my item2   </item2>
    </myXML>
    Using RatupreXML parsing, how can i get a name of each tag .. I did tried

    Code:
    RXMLElement *tmp =   [RXMLElement elementFromXMLFile:@"sample.xml"];
    NSArray      *arr  =   [tmp child:nil];
    for ( id obj in arr )
        NSLog(@" obj in arr is %@ ", (NSString*)obj );
    Result shown on the console is

    Code:
    obj in arr is this is my item1
    obj in arr is this is my item2
    Any idea how to achieve tagName item1 and item2 . Please advice me. Thanks
     
  2. KnightWRX macrumors Pentium

    KnightWRX

    Joined:
    Jan 28, 2009
    Location:
    Quebec, Canada
  3. tranvutuan thread starter macrumors member

    Joined:
    Dec 19, 2011
    #3
  4. jnoxx macrumors 65816

    jnoxx

    Joined:
    Dec 29, 2010
    Location:
    Aartselaar // Antwerp // Belgium
    #4
    Please set your thread as resolved than, the community of MacRumors then know this is the correct answer, we will thank you ^_-
     

Share This Page