Reputation: 37
I am fairly new to iOS development and trying make a simple app which will communicate with PHP API. Data request and response will be in XML format only..
this is my php method for login,
function login()
{
$mainframe = JFactory::getApplication();
$xmlcnt = array();
if (!isset($HTTP_RAW_POST_DATA))
{
$HTTP_RAW_POST_DATA = file_get_contents("php://input");
}
if(empty($HTTP_RAW_POST_DATA))
{
$xmlcnt['code'] = "2";
return $xmlcnt;
}
$doc = new DOMDocument();
$doc->loadXML( $HTTP_RAW_POST_DATA);
$login_data = $doc->getElementsByTagName( "data" );
foreach( $login_data as $login )
{
$user_nm = $login->getElementsByTagName( "username" );
$user_nm = $user_nm->item(0)->nodeValue;
$password = $login->getElementsByTagName( "password" );
$password = $password->item(0)->nodeValue;
} ......
and the xmldata look like this "<data><username>testuser</username><password>password</password></data>
"
i want to understand how/what should i use in xcode objective-c to send and recieve XML efficiently.
Thank you verymuch
Upvotes: 1
Views: 633
Reputation: 1334
you can check an XML parser for that, here some examples: http://cocoawithlove.com/2011/05/classes-for-fetching-and-parsing-xml-or.html
Upvotes: 1
Reputation: 2779
If you are asking which xml parser to use, Writing your own parser should help a lot in performance. We usually add data compression to keep size of data transfer low. We use simple zip library and also do encryption is needed. Zipping will help a lot if the data size is large
Upvotes: 0