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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:41:07+00:00 2026-05-22T19:41:07+00:00

I’m replacing a simple initWithContentsOfURL: with a dynamic HttpGet where I pass two parameters

  • 0

I’m replacing a simple initWithContentsOfURL: with a dynamic HttpGet where I pass two parameters and that webpage returns the exact same data as XML in text format.

Must I really parse the data to get it into an array of dictionaries? I was hoping for NSXMLParser initWithData: and then some automated way of initalizing an NSArray with all nodes, structure following the XML. (It is a plist in XML format, so the structure and all key names are already in it. Why should I have to write a replica of all that in Objective-C as well?!)

I’d be happy with httpgetting to a text file and then NSArray initWithContentsOfFile.

Edit: This yields an NSData object 26K in size, but the error message “Conversion of the string failed. The string is empty”.

//Initiate connection
NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease]; [request setURL:url(aspurl)];
[request setHTTPMethod:@"GET"];
    //keep adding your headers this way
NSString *accept = [NSString stringWithFormat:@"application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,/*;q=0.5"];
[request addValue:accept forHTTPHeaderField: @"Accept"];
    //send request & get response
NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];

NSString *errString;
NSMutableArray *arr=[NSPropertyListSerialization propertyListFromData:returnData
                                         mutabilityOption:NSPropertyListMutableContainers
                                                   format: NULL 
                             errorDescription:&errString];

if (errString)
{
    NSLog(@"%@",errString);
    [errString release]; // exception to the rules
}

This gives the error “Conversion of string failed. The string is empty.” and arr is 0x0.

Can anyone point out my mistake?

  • 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-22T19:41:08+00:00Added an answer on May 22, 2026 at 7:41 pm

    First-off, you could use a class like XML-to-NSDictionary to do the parsing, and it could be dead simple, but it seems you don’t like that approach.

    Since you are dealing with a plist, as an alternative, you can:

    1. use NSURLConnection to load the plist into an NSData;
    2. use [NSPropertyListSerialization propertyListFromData:mutabilityOption:format:errorDescription:method] to convert that into an NSDictionary/NSArray;

    Have also a look at Property List Programming Guide.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I've got a string that has curly quotes in it. I'd like to replace
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into
I'm making a simple page using Google Maps API 3. My first. One marker
I have some data like this: 1 2 3 4 5 9 2 6
I'm trying to create an if statement in PHP that prevents a single post

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.