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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:33:50+00:00 2026-05-31T00:33:50+00:00

I have implemented the NSXMLParserDelegate protocol and appear to be successfully parsing XML with

  • 0

I have implemented the NSXMLParserDelegate protocol and appear to be successfully parsing XML with NSXMLParser. The XSD for the XML I am parsing is fairly involved with 100 or so tags and attributes, that can get rather deeply nested at times. I am populating an object hierarchy from the data in the XML documents and all seems to be going well so far.

My question is, how do I effectively test this? There is a lot of “if/else if” logic in my delegate as well as as BOOL flags to keep track of where I am in within the document being parsed. I could have easily introduced a typographical error while writing the delegate.

My initial inclination is to create a test input document that uses all of the elements and attributes specified in the XSD. Once it has been parsed, I could “NSLog()” everything that has been inserted into the object hierarchy, but that seems too labor intensive.

Is there a better way to think about this problem, or shall I just roll up my sleeves and brute force it?

  • 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-31T00:33:52+00:00Added an answer on May 31, 2026 at 12:33 am

    You’ll want to look at using a unit test here. If you can generate one (or more) files that will result in known data structures, you can parse them in unit tests and verify that the data structures are what you expect them to be.

    We do this with a lot of XML file types that we manage for both parsing and generation (and for fun, we hook up the output of the generator to the parser in another unit tests).

    There is a lot of good background information on setting up Unit Tests from Apple, and a lot of Open Source projects use Unit Testing as well.

    With a scheme like this, you end up writing a comparator (or using isEqual: if that works for your object hierarchy) and then you can reuse that for each of your tests. Add a few XML files and manually create the matching object hierarchy in your Unit Tests and you’re all set to go.

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

Sidebar

Related Questions

i have implemented galleryview in one screen named display_image.xml in which i have shown
I have implemented NSXMLParser in my app and I am reviewing alternatives. My complaints
I have implemented SSO for tomcat using the valve in the config.xml however all
I have implemented the Google map successfully. But one more thing has left to
I have implemented what I thought was a pretty decent representation of MVC in
I have implemented a simple file upload-download mechanism. When a user clicks a file
I have implemented a python webserver. Each http request spawns a new thread. I
I have implemented a SAX parser in Java by extending the default handler. The
I have implemented VirtualPathProvider class so I can keep all my views in the
I have implemented tracing based on System.Diagnostics. I am also using a System.Diagnostics.TextWriterTraceListener, and

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.