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

  • Home
  • SEARCH
  • 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 9239353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:58:06+00:00 2026-06-18T07:58:06+00:00

I am using XMLReader for converting xmlString to NSDictionary and it is working fine

  • 0

I am using XMLReader for converting xmlString to NSDictionary and it is working fine to some of the xml string.But it is giving null dictionary for xml displayed below

<?xml version=\"1.0\"?>
<THEME>
    <OBJ>
        <FORMBG>0x00E0E0E0</FORMBG>
        <ALERTBG>0x00B4B4B4</ALERTBG>
        <FORMFONT>0x0033001A</FORMFONT>
        <FORMFONT2>0x00575757</FORMFONT2>
        <FORMFONT3>0x003E3E37</FORMFONT3>
        <ROWSELECTORLIST>0x0000CC33</ROWSELECTORLIST>
        <ROWDIVIDER>0x00BBBBBB</ROWDIVIDER>
        <SUBHEADER>0x00A8A8A8</SUBHEADER>
        <SELECTORCOMPONENT>0x00C2C2C2</SELECTORCOMPONENT>
        <FOOTER>0x00796767</FOOTER>
    </OBJ>
</THEME>

my conversion code is as follows:

NSString *stringURL=[NSString stringWithFormat:@"http://202.58.232.138/mt/theme.aspx"];
NSURL *url=[NSURL URLWithString:stringURL];

NSMutableURLRequest *request=[[NSMutableURLRequest alloc] initWithURL:url];
NSError *error;
NSURLResponse *response;
NSData *urlData=[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];

NSString *responseString=[[NSString alloc] initWithData:urlData encoding:NSUTF8StringEncoding];
NSLog(@"response string is %@",responseString);

NSDictionary *dictionary=[XMLReader dictionaryForXMLString:responseString error:nil];

The url is printing following data on browser

    0x00E0E0E00x00B4B4B40x0033001A0x005757570x003E3E370x0000CC330x00BBBBBB0x00A8A8A80x00C2C2C2
0x00796767

and printing on xcode log will display following data.

<?xml version=\"1.0\"?>
<THEME>
    <OBJ>
        <FORMBG>0x00E0E0E0</FORMBG>
        <ALERTBG>0x00B4B4B4</ALERTBG>
        <FORMFONT>0x0033001A</FORMFONT>
        <FORMFONT2>0x00575757</FORMFONT2>
        <FORMFONT3>0x003E3E37</FORMFONT3>
        <ROWSELECTORLIST>0x0000CC33</ROWSELECTORLIST>
        <ROWDIVIDER>0x00BBBBBB</ROWDIVIDER>
        <SUBHEADER>0x00A8A8A8</SUBHEADER>
        <SELECTORCOMPONENT>0x00C2C2C2</SELECTORCOMPONENT>
        <FOOTER>0x00796767</FOOTER>
    </OBJ>
</THEME>

I think that’s why it is not converting to NSDictionary.
please help If you have faced such a problem before.
When you pass above xml data to for [XMLReader dictionaryForXMLString:responseString error:nil];
at the place of response string then it will work perfectly.But if you execute above code it will display dictionary =(null).

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-18T07:58:07+00:00Added an answer on June 18, 2026 at 7:58 am

    Finally found the mistake:

    it is counting escape sequence in response string.That’s why not parsing to NSDictionary.
    I have added below line to replace escape sequence with blank.

    NSString *responseString=[[NSString alloc] initWithData:urlData encoding:NSUTF8StringEncoding];
    responseString=[responseString stringByReplacingOccurrencesOfString:@"\\" withString:@""];
    

    Now my code is running perfectly.
    output is showing below after parsing.

    xml dictianary is {
    THEME =     {
        OBJ =         {
            ALERTBG =             {
                text = 0x00B4B4B4;
            };
            FOOTER =             {
                text = 0x00796767;
            };
            FORMBG =             {
                text = 0x00E0E0E0;
            };
            FORMFONT =             {
                text = 0x0033001A;
            };
            FORMFONT2 =             {
                text = 0x00575757;
            };
            FORMFONT3 =             {
                text = 0x003E3E37;
            };
            ROWDIVIDER =             {
                text = 0x00BBBBBB;
            };
            ROWSELECTORLIST =             {
                text = 0x0000CC33;
            };
            SELECTORCOMPONENT =             {
                text = 0x00C2C2C2;
            };
            SUBHEADER =             {
                text = 0x00A8A8A8;
            };
        };
    };
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I read xml-string using XmlReader with code: XmlReader reader = XmlReader.Create(new StringReader(xmlString)); while (reader.Read())
I want to save and load my xml data using XmlReader. But I don't
I'm using an XmlReader to iterate through some XML. Some of the XML is
I am trying to parse an xml file using XmlReader but although I am
I'm having some trouble using XmlReader to read an XML file. I can open
I want to read a XML file, using XMLReader but the END ELEMENT is
Im converting an XML String into an array using XML reader. The parser is
Im using XMLReader to parse XML but i've come across a situation where two
I am using XMLReader to read a large XML file with about 1 million
I'm pulling my hair out on this. I do some manual deserialization using XmlReader

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.