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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:26:18+00:00 2026-05-24T10:26:18+00:00

I have done a basic http post to a server and received XML data

  • 0

I have done a basic http post to a server and received XML data back, so that is good.

So then, I decided to install MAMP and create my first php page 😉

From all of the googling I have done, I suspect that it is a utf-8/encoding/newline issue, but it is driving my bonkers 😉

The php server gets the http post data, but can’t convert into XML so it is failing at that point (see debug at end and variable is empty).

thanks for any suggestions!

Here is the objective-c:

NSString *postString = [NSString stringWithString:@"xml=<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n"];
postString = [postString stringByAppendingString:@"<note>\r\n"];
postString = [postString stringByAppendingFormat:@"<tasks>%@</tasks>\r\n", @"task1234"];
postString = [postString stringByAppendingFormat:@"<details>%@</details>\r\n", @"det1"];
postString = [postString stringByAppendingString:@"</note>\r\n"];

NSURL *url = [NSURL URLWithString:@"http://localhost:8888/xmltest.php"];
NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url];
NSString *msgLength = [NSString stringWithFormat:@"%d", [postString length]];

[req addValue:@"application/x-www-form-urlencoded charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[req setHTTPMethod:@"POST"];
[req addValue:msgLength forHTTPHeaderField:@"Content-Length"];
[req setHTTPBody:[postString dataUsingEncoding:NSUTF8StringEncoding]];

And here is the PHP:

<?php
$form_input = $_POST['xml'];  
$objDOM = new DOMDocument();
$objDOM->loadXML($form_input);
echo "here1: $form_input \n";

$note = $objDOM->getElementsByTagName("note");
echo "here2\n";
print_r ($note);

foreach( $note as $value )
{
  echo "here3\n";
  $tasks = $value->getElementsByTagName("tasks");
  $task  = $tasks->item(0)->nodeValue;
  echo "$task :: $detail <br>";
}

And the debug output:

here1: <?xml version=\"1.0\" encoding=\"utf-8\"?>
<mynotes>
<note>
<tasks>task1234</tasks>
<details>details1234</details>
</note>
</mynotes>

here2
DOMNodeList Object
(
)
  • 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-24T10:26:18+00:00Added an answer on May 24, 2026 at 10:26 am

    Try ASIHTTPRequest

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

Sidebar

Related Questions

The last GUI programming I have done was with Visual Basic, which included objects
I have done a bit of testing on this myself (During the server side
I have done a bit of research into this and it seems that the
I've a basic php script set up on a web server to accept xml
Hi I have found an article on implementing OpenID on my C# site http://madskristensen.net/post/OpenID-implementation-in-Csharp-and-ASPNET.aspx
I have a HTTP sever in one program and my basic application in another
We have done some basic TCP communication, but have a few questions. We are
I have a basic HTML form that I am centering. I am using jQuery
I have a very basic application done in Sinatra I have deployed it in
I have a basic question. 1- I want to use Science.dll provided at http://www.sciencecode.com/

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.