Jump to content


New Members
  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About TBrass84

  • Rank
  1. I want to edit an xml using PHP and POST from iOS app. The XML Looks like: <?xml version="1.0" encoding="UTF-8"?> <rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"> <channel> <atom:link rel="self" type="application/rss+xml" href="http://www.316apps.site90.net/Test.xml"/> <lastBuildDate>Mon, 3 Feb 2014 09:26:14 -0500</lastBuildDate> <title>Prayer Warrior</title> <description><![CDATA[Prayer Warrior]]></description> <link>http://www.316apps.site90.net</link> <language>en</language> <copyright>2014 Prayer Warrior</copyright> <item> <first_name>John</first_name> <last_name>Doe</last_name> <title>I need money</title> <date>Mon, 3 Feb 2014 09:26:14 -0500</date> <anonymous>No</anonymous> <prayer_warriors>1</prayer_warriors> <location>USA</location> </item> <item> <first_name>Jane</first_name> <last_name>Doe</last_name> <title>I need money</title> <date>Tue, 4 Feb 2014 09:26:14 -0500</date> <anonymous>No</anonymous> <prayer_warriors>1</prayer_warriors> <location>USA</location> </item> </channel> </rss> Over time, the XML will grow. In my iOS app I have a UITableView that parses the XML into different rows. When they view a row, I want it to increase the count on the prayer. PHP I am using now is: <?php $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; $title = $_POST['title']; $xml = simplexml_load_file("http://www.316apps.site90.net/Test.xml") or die("Not loaded!\n"); $responses = $xml->xpath("//channel/item[title = $title and first_name = $first_name and last_name = $last_name]/prayer_warriors"); $responses[0][0] = $responses[0] + 1; print_r($responses); $xml->asXML("Test.xml"); ?> The iOS app uses this code for POST to it: RSSEntry *entry = [_allEntries objectAtIndex:indexPath.row]; NSString *myRequestString = [NSString stringWithFormat:@"first_name=%@&last_name=%@&title=%@", entry.firstName, entry.lastName, entry.prayerRequest]; // Create Data from request NSData *myRequestData = [NSData dataWithBytes: [myRequestString UTF8String] length: [myRequestString length]]; NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL: [NSURL URLWithString: @"http://www.316apps.site90.net/Increase.php"]]; // set Request Type [request setHTTPMethod: @"POST"]; // Set content-type [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"content-type"]; // Set Request Body [request setHTTPBody: myRequestData]; // Now send a request and get Response NSData *returnData = [NSURLConnection sendSynchronousRequest: request returningResponse: nil error: nil]; // Log Response NSString *response = [[NSString alloc] initWithBytes:[returnData bytes] length:[returnData length] encoding:NSUTF8StringEncoding]; NSLog(@"Response%@",response); However, nothing changes, and I get an invalid predicate message on the response on my iPhone for the line: $responses = $xml->xpath("//channel/item[title = $title and first_name = $first_name and last_name = $last_name]/prayer_warriors"); Thoughts?

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.