Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6661917
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:20:06+00:00 2026-05-26T02:20:06+00:00

So I know how to parse some XML structures but I am currently trying

  • 0

So I know how to parse some XML structures but I am currently trying to parse this specific xml structure thats a bit different to what I am used to.

normally I would parse something like

<xml>
  <data>
    <name>Forrest</name>
    <age>25</name>
    <username>forrestgrant</username>
  </data>
</xml>

But now I’m working with some xml like so..

<xml>
  <data name="Forrest" age="25" username="forrestgrant" />
  <other value="6" />
</xml>

how do I access those variables when they are structured like this?
This is how I would normally approach this task, which is baised of searching for the title tags and getting the data from each one.. however I am now trying to figure out how to parse this other style of xml.

- (void)startTheParsingProcess:(NSData *)parserData
{
    [myDataArray release]; // clears array for next time it is used.
    myDataArray = [[NSMutableArray alloc] init]; //initalizes the array

    NSXMLParser *parser = [[NSXMLParser alloc] initWithData:parserData]; //incoming parserDatapassed to NSXMLParser delegate which starts parsing process 

    [parser setDelegate:self];
    [parser parse]; //Starts the event-driven parsing operation.
    [parser release];
}

- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict
{
    if ([elementName isEqual:@"item"]) {
        // NSLog(@"Found title!");
        itemString = [[NSMutableString alloc] init];
    }
}

- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
{
    [itemString appendString:string];
}

- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
{
    if ([elementName isEqual:@"item"]) {
        //NSLog(@"ended title: %@", itemString);
        [myDataArray addObject:itemString]; //this is where i pass the values over to my array.

        [itemString release];
        itemString = nil;
    }
}

- (void)parserDidEndDocument:(NSXMLParser *)parser
{
    // Passes myDataArray to the method that will sort and display the array into a uitableview.
    [self startSortingTheArray:myDataArray];
}

any help would be greatly appreciated..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T02:20:07+00:00Added an answer on May 26, 2026 at 2:20 am

    The xml data above provides the data as attributes on the xml element.

    This callback method gives you access to the attributes as a dictionary of key values (attributeDict).

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

    NSLog the dictionary out in that method to see the values:

    NSLog(@"attributes: %@", attributeDict);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey guys, I want to parse some xml but I don't know how I
I am trying to parse this xml file, which has some nested nodes. I
I'm trying to parse some XML (html) I downloaded using WebRequest.Create() and then read
I already know that parse the wowarmoy's xml to get the data. But there
I am trying to parse an xml file using XmlReader but although I am
i'm having some troubles trying to parse an XML file and display the results
I'm trying to parse some of my first XML documents in SAX by simply
I want to parse some large XML file using linq to XML but I
I'm trying to parse some poorly generated xml code with scala that looks like
I'am currently trying to create and application (In c#) that parse a XML file

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.