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 8227345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:05:59+00:00 2026-06-07T16:05:59+00:00

I have got an object serialization from Java into a XML file that I

  • 0

I have got an object serialization from Java into a XML file that I have to deserialize for an iOS App using objective-c.

I am using NSXMLParser for the first time and have a given object structure in objective-c.

Here is a sample of the XML file:

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<Content.Project>
  <versionName>0.5.241</versionName>
  <spriteList>
    <Content.Sprite>
      <costumeDataList>
        <Common.CostumeData>
          <costumeFileName>CCE87ECA859D4448BC47A837CF024464_background</costumeFileName>
          <costumeName>background</costumeName>
        </Common.CostumeData>
      </costumeDataList>
      <soundList/>
      <scriptList>
        <Content.StartScript>
          <brickList>
            <Bricks.SetCostumeBrick>
              <costumeData reference="../../../../../costumeDataList/Common.CostumeData"/>
              <sprite reference="../../../../.."/>
            </Bricks.SetCostumeBrick>
          </brickList>
          <sprite reference="../../.."/>
          <name>stageStartScript</name>
        </Content.StartScript>
      </scriptList>
      <name>Background</name>
    </Content.Sprite>
...

Then I have given classes (derived from NSObject) for certain sections of the XML, such as a Level that contains an array of Sprites and the Sprite class in turn contains an array of Costumes and so on…

My problem is that the XMLParser does not really ‘know’ to which class the value corresponds. I have to differ between the different classes to set the corresponding properties.

For example, the following line works for all properties of the Level object (the first level of <Content.Project> but not <spriteList> and so on):
[self.level setValue:self.currentElementValue forKey:elementName];

So basically my question is: Is there a way to distinguish between the different ‘levels’ or ‘depth’ in an XML file in the…

- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName
  namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName 

… method of the parser?

I am sure there must be an easy way to achieve this but I have not found one on google.
Thanks in advance.

  • 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-06-07T16:06:01+00:00Added an answer on June 7, 2026 at 4:06 pm

    Make a depth counter. Increase it in didStartElement, and decrease it in didEndElement 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a bytearray object in Python 2.7 that I got from a query
I have got a problem with Java serialization. Suppose I had one Object persisted
I have a strange problem with object serialization. in the file documentation it states
I have a static library that i made for encryption an XML serialization with
I have got this result using json decode from an api call. but I
I've got an object that im reading and writing to and from fileinputstreams/objectinputstreams and
I have a client and server application that transfer message using serialization over TCP.
I've got the class object for an enum (I have a Class<? extends Enum>
I've got the design habit to have a SqlConnection object populated by a child
I have my domain object, Client , I've got a form on my JSP

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.