Welcome Guest, Not a member yet? Register   Sign In
How to POST XML data in codeigniter?

i have a problem while posting xml data to a url .....
could someone give me an example how to posting xml????

Why you need to post XML data with URL??
What are you trying to do?

i want to develop web service client with codeigniter.. so i have to post data with xml format...

for example :
i want to post this xml :

xml data above would be post to url (http://example.com:9090/resource/customer/add)

could u help me how to do it ???

You can't post XML data to url,
URL grabs XML data or prints it.

Is there any way that [http://example.com:9090/resource/customer/add] will grab the given XML?

Really ????
this url[http://example.com:9090/resource/customer/add] consumes xml data..
so, i have to post xml ...
i think we can post xml data.. because i have been developing desktop application with that web service and worked properly

Maybe you send it with regular POST and Form and then it builds the XML by itself.

i have been solved the problem with using curl to post xml data
Thanks Wink

You mind sharing the code?
I'm trying to understand what you did and meant exactly.

okay.. i will share the code Smile..
i want to post xml to web service server..

so i write controller like this :

function add_customer() {

$post = "&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n\n";
$post .= "<customer>\n";
$post .= "<firstname>sinichi</firstname>\n";
$post .= "<lastname>kudo</lastname>\n";
$post .= "</customer>\n";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$res = curl_exec($ch);
curl_close ($ch);
echo $res;

controller above have a function to post xml data to web service server using curl Smile..
are you understand my problem previously now ? Smile

Theme © iAndrew 2016 - Forum software by © MyBB