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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:00:54+00:00 2026-06-01T18:00:54+00:00

In XML struct i have: <font fontsize=10 fontcolor=#000000 fontface=file.ttf/> How do i get fontsize,

  • 0

In XML struct i have:

<font fontsize="10" fontcolor="#000000" fontface="file.ttf"/>

How do i get fontsize, color and face using NSXMLParser?
Of course i have the standard implementation

-(id)init
{
    self = [super init];

    parser = [[NSXMLParser alloc] initWithContentsOfURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"myxmlfile" ofType:@"xml"]]];

    [parser setDelegate:self];
    [parser parse];

    return self;
}

- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict 
{
    NSLog(@"Started Element %@", elementName);
    element = [NSMutableString string];
}

- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
{
    NSLog(@"Found an element named: %@ with a value of: %@", elementName, element);
}

- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
{
    if (element == nil)
        element = [[NSMutableString alloc] init];
    [element appendString:string];
}

And it works beautifly for a <mytag>something</mytag>. How to get tag attributes?

  • 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-01T18:00:56+00:00Added an answer on June 1, 2026 at 6:00 pm

    Your attributeDictionary from

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

    contains them. Just call [atrributeDict objectForKey:@"fontColor"] for example

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

Sidebar

Related Questions

I have the following XML file and I want to store it using the
I have a small XML file: <wddxPacket version='1.0'> <header/> <data> <struct type='coldfusion.runtime.ArgumentCollection'> <var name='HEADLINE'>
I have the following XML file: <?xml version='1.0'?> <preferences> <font role=console> <fname>Courier</fname> <size>9</size> </font>
I have some XML structures like this: var struct:XML = <mh> <mi id=1 stuff=whatever/>
I have this XML file that I parse into its elements and create a
I have two sources: an xml-file containing definitions of several hundred data structures, basically
i have some issue to navigate on my XML File. Here is the structure
I have this structure which I want to write to a file: typedef struct
I have a program that reads an XML file (for now, on local computer.)
we have XSLT to transform XML into HTML in XHTML 1.0 Strict in XSLT

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.