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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:20:48+00:00 2026-05-28T18:20:48+00:00

How to do a parsing of nested nodes with NSXMLParser. Since this parser is

  • 0

How to do a parsing of nested nodes with NSXMLParser. Since this parser is know to parse XML node-wise manner, how should we handle multiple node parsing with same names like below:

<data>
    <nodesame attrisame="this is same">
         <nodesame> this is also same </nodesame>
         <nodedifferent> this is different although </nodedifferent>
    </nodesame>
</data>

In above we have a master data node which contains nodesame node which contains another nodesame node inside. Please tell me as to how differentiate both nodesame with different context.

Please suggest me some good way for getting the dictionary/array from the delegate:

parser:didEndElement:namespaceURI:qualifiedName

I am famaliar with libxml2 and touchXML but using NSXMLParser is making me crazy plus we have to use the same because the code we have uses the NSXMLParser, so changing it to Libxml will take a hell.

  • 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-28T18:20:49+00:00Added an answer on May 28, 2026 at 6:20 pm

    When you use nsxmlparser, it goes from top to bottom, and it calls matching pairs of didStartElement and didEndElement. So, for your first question (how to know when you are within a child node of the same name as a parent node?), the answer is to keep track of when didStartElement was called, followed by another didStartElement of the same node name without a call to didEndElement in between.

    Now, each element is named so an array isn’t really applicable for general parsing. It’s only viable in a JSON response.
    So for your second question, (how to create an array or dictionary of the xml?), is to let each node be a dictionary of its own, perhaps with a key of “attributes” that’s another dictionary. I would create something like this for your example:

    {"data":
        {"nodesame":
            {"attributes":
                 {"attrisame":"this is same"}
            }, {"nodesame":
                   {"text":"this is also same"}
            }, {"nodedifferent":
                   {"text":"this is different although"}
            }
        }
    }
    

    One of the problems here is occupying the words “attributes” and “text”, so it’s not a pretty solution.

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

Sidebar

Related Questions

I'm parsing some xml, and given a particular node, I'm trying to figure out
I tried parsing this huge XML document using XML minidom . While it worked
I am parsing an RSS feed from the following URL: http://rss.sciam.com/ScientificAmerican-Global?format=xml // $xml_text is
I have a large nested array that I'm generating from parsing a CSV file
I have <asp:RegularExpressionValidator ValidationExpression="\d+{1,4}(?:[.,]\d{1,4})?" /> but it doesn't' work, parser throws ArgumentException: parsing "\d+{1,4}(?:[.,]\d{1,4})?"
I've got a xml that I'm parsing and trying to extract some data from.
I have a several tables nested within a table that I am parsing using
This question got me thinking: should we apply the principle that flat is better
Is running a nested NSScanner the most efficient method for parsing out a string
My problem is im creating a large nested PHP array which is parsing information

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.