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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T03:37:51+00:00 2026-06-05T03:37:51+00:00

This is a xml structure that I want to parse using libxml parsing. How

  • 0

This is a xml structure that I want to parse using libxml parsing.

enter image description here

enter image description here

How can i get the attribute value for "campaign" tag i.e ID and for the "image" tag i.e url and size.

If I use these values, i can extract the values of "code" tag and "name " tag.

static const char *kName_campaign = "campaign";
static const NSUInteger kLength_campaign = 9;
static const char *kName_code = "code";
static const NSUInteger kLength_code = 5;
static const char *kName_name = "name";
static const NSUInteger kLength_name = 5;

Then I get the code and name of current and upcoming campaign all together.
This is the code I use in the delegate which gets called when parsing is done.

static void endElementSAX(void *ctx, const xmlChar *localname, const xmlChar *prefix, const xmlChar *URI)
{    
    LibXMLParser *parser = (LibXMLParser *)ctx;
    
    if (parser.parsingASong == NO) return;
    
    if (prefix == NULL)
    {
        if (!strncmp((const char *)localname, kName_campaign, kLength_campaign)) 
        {
            [parser finishedCurrentSong];
            parser.parsingASong = NO;
        } 
        else if (!strncmp((const char *)localname, kName_code, kLength_code))
        {
            parser.currentSong.title = [parser currentString];
            NSLog(@"Code  :: %@",[parser currentString]);
        }
        else if (!strncmp((const char *)localname, kName_name, kLength_name)) 
        {
            parser.currentSong.category = [parser currentString];
            NSLog(@"Name :: %@",[parser currentString]);
        }
    }
}

How can i get the attributes values from start to bottom of id from "campaign" tag. url and size from "image" tag?

  • 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-05T03:37:52+00:00Added an answer on June 5, 2026 at 3:37 am
    static void startElementSAX(void *ctx, const xmlChar *localname, const xmlChar *prefix, const xmlChar *URI, int nb_namespaces, const xmlChar **namespaces, int nb_attributes,
    int nb_defaulted, const xmlChar **attributes)
    {
    
    if (nb_attributes > 0)
    {
        NSMutableDictionary* attributeDict = [NSMutableDictionary dictionaryWithCapacity:(NSUInteger)[NSNumber numberWithInt:nb_attributes]];
        for (int i=0; i<nb_attributes; i++)
        {
           NSString* key = [NSString stringWithCString:(const char*)attributes[0] encoding:NSUTF8StringEncoding]; 
           NSString* val = [[NSString alloc] initWithBytes:(const void*)attributes[3] length:(attributes[4] - attributes[3]) encoding:NSUTF8StringEncoding];
           attributes += 5;
    
           [attributeDict setValue:val forKey:key];
        }
     }
    }
    

    Try this..

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

Sidebar

Related Questions

I'm using Android's XML parsing helper ( android.util.Xml.parse(InputStream, Encoding, ContentHandler ) to parse this
I have a directory structure that looks like this: /a/f.xml /b/f.xml /c/f.xml /d/f.xml What
I have an xml file that contains a structure.. In this structure, I have
Given an XML structure like this: <garage> <car>Firebird</car> <car>Altima</car> <car>Prius</car> </garage> I want to
I've a XML structure like this: <root> <element> <name>Foo</name> <subelement> <key>1.1</key> <value>Lorem ipsum</value> </subelement>
I would like copy just file.xml without folder structure using overlays like this: <overlays>
I currently have an XML Structure that looks something like this <Parent> <Info> <Info-Data></Info-Data>
I am trying to parse some XML that looks similar to this: <document> <headings>
I've got this data I get from an XML feed and parse as NSDictionaries.
I have class model for XML structure, where i want parse xml into it.

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.