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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:12:50+00:00 2026-05-23T15:12:50+00:00

So my iPhone app sends a shopping cart in a XML file to a

  • 0

So my iPhone app sends a shopping cart in a XML file to a URL through POST. Here is the line of code that does that

NSString *pathToSerializedCart = [rootPath stringByAppendingPathComponent:@"serializedCart.plist"];
NSString *shoppingCartString;
NSData *serializedData;
if (![fileManager fileExistsAtPath:pathToSerializedCart])
   {
    NSLog(@"ERROR:\nCouldnt find serialized cart in documents folder.");
    return;
   }


    serializedData = [NSData dataWithContentsOfFile:pathToSerializedCart];
    shoppingCartString = [[NSString alloc] initWithData:serializedData
                                                        encoding:NSUTF8StringEncoding];
    NSLog(@"%@", shoppingCartString);
    [shoppingCartString release];


    //==========================================================================


NSData *returnData = [NSURLConnection sendSynchronousRequest:request 
                                           returningResponse:nil error:nil];
NSString *returnString = [[NSString alloc] 
                          initWithData:returnData encoding:NSUTF8StringEncoding];
NSLog(@"%@",returnString);
[returnString release];

Now what Id like to do is put a script on the server in the file welcome.php so that the contents of this XML file are echoed to the browser.

I’ve looked at many examples but they all talk about the situation where the XML file is present in the same directory as the PHP file on the server. I haven’t been able to find examples of PHP code that actually is evoked from an app.

Could someone please point me to the right direction.

Thanks

  • 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-23T15:12:50+00:00Added an answer on May 23, 2026 at 3:12 pm

    UPDATE After seeing your full objc, I think the POST value name in question is userfile and I’ve updated the code below.

    In PHP, the filename location of your uploaded file will reside in $_FILES['userfile']['tmp_name']. It is recommended to var_dump($_FILES) so you can understand how PHP treats the uploaded file.

    The function file_get_contents() will read that temporary filename and return its contents as a string, which you can load into DOMDocument, as in the last bit of code below..

    Recommended reading: PHP docs on the $_FILES superglobal array

    You’ll need to retrieve your XML data from the $_POST[] superglobal, and then you can parse it with simplexml_load_string().

    // Sorry I'm unfamiliar with objC, so I can't glean the actual POST 
    // value name from your code
    // UPDATE misunderstood. the uploaded file is in $_FILES
    // indexed by the POST key name.
    
    // In development you can inspect your POST...
    // To see the contents of your POST in PHP, do:
    var_dump($_POST);
    // Also check the contents of $_FILES
    var_dump($_FILES);
    
    // Your file is stored in the temp directory 
    $xmlfile = $_FILES['userfile']['tmp_name'];
    
    // Load it with SimpleXML
    $xml = simplexml_load_file($xmlfile);
    

    Or instead of SimpleXML I usually prefer the more flexible PHP DOMDocument library:

    $xmlfile = $_FILES['userfile']['tmp_name'];
    $dom = new DOMDocument();
    $dom->loadXML(file_get_contents($xmlfile));
    
    // Now parse it as necessary using DOM manipulators
    $tags = $dom->getElementsByTagName("sometag");
    foreach ($tags as $sometag) {
       // whatever...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got an iPhone App that is supposed to send POST data to my
I am developping an iPhone App that sends SMS, I am using XCode 4.2
I want to make an iPhone app that sends some data to a PHP
I have a shopping cart in my iPhone app. Once the user is done
I have an iPhone app which sends a request to a url posting a
I have an app [iphone], that sends to a server some times [using json],
I have couple of iPhone apps that sends an email via code. I've noticed
My iPhone app sends a message to a server via HTTP post. I would
I have an iphone app that sends and retrieves data from a php script.
I have a client that wants an iPhone app that at some point sends

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.