Question : Curl API , XML parsing problem ?

Hi !
I am using Curl to interact API through XML...
I am getting XML  parsing error..but XML is properly formed. The code to communicate with API is given below.

Kindly suggest ?

regards
sd

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
<?php 

		$url= "http://api.XXXXXXXX.com";
		
		$UserId="XXXXXXXXX";
		$UserPassword="XXXXXXXXXXXXX";
		$VendorId="XXXXXXXXXXX";
		$VendorPassword="XXXXXXXXXXXXX";
 		
		$cr="";
		$GetRoomTypesRequest ="";
		$GetRoomTypesRequest ='<?xml version="1.0" encoding="utf-8"?>'.$cr;
		$GetRoomTypesRequest =$GetRoomTypesRequest .'<GetRoomTypes>'.$cr;
		$GetRoomTypesRequest =$GetRoomTypesRequest .'<Auth>'.$cr;
		$GetRoomTypesRequest =$GetRoomTypesRequest .'<UserId>'.$UserId.'</UserId>'.$cr;
		$GetRoomTypesRequest =$GetRoomTypesRequest .'<UserPassword>'.$UserPassword.'</UserPassword>'.$cr;
		$GetRoomTypesRequest =$GetRoomTypesRequest .'<VendorId>'.$VendorId.'</VendorId>'.$cr;
		$GetRoomTypesRequest =$GetRoomTypesRequest .'<VendorPassword>'.$VendorPassword.'</VendorPassword>'.$cr;
		$GetRoomTypesRequest =$GetRoomTypesRequest .'<PropertyId>63</PropertyId>'.$cr;
		$GetRoomTypesRequest =$GetRoomTypesRequest .'</Auth>'.$cr;
		$GetRoomTypesRequest =$GetRoomTypesRequest .'</GetRoomTypes>';
		
		$data_string=trim($GetRoomTypesRequest);
		 
		
		 
		$filename="GetRoomTypes";
		
		//$headerarr=array('Content-Type: text/xml');
		$headerarr = array( 
            "Content-type: text/xml;charset=\"utf-8\"", 
            "Accept: text/xml", 
            "Cache-Control: no-cache", 
            "Pragma: no-cache", 
            "SOAPAction: \"run\"", 
            "Content-length: ".strlen($data_string)
                   ); 
		
		$file=fopen($filename.'Request.xml',"w+");
		fwrite($file, $data_string);
		fclose($file);
 
		 
		 
        
		$curl_handle = curl_init ();
		curl_setopt ($curl_handle, CURLOPT_URL, $url);
		curl_setopt($curl_handle, CURLOPT_HTTPHEADER,$headerarr); 
		curl_setopt($curl_handle, CURLOPT_HEADER, 0); 
		curl_setopt ($curl_handle, CURLOPT_FOLLOWLOCATION, 1);
		curl_setopt ($curl_handle, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt ($curl_handle, CURLOPT_POST, 1);
		curl_setopt ($curl_handle, CURLOPT_POSTFIELDS, $data_string);
		// Perform the POST and get the data returned by the server.
		$result = curl_exec ($curl_handle) or die ("There has been a CURL_EXEC error");
		// Close the CURL handle
		curl_close ($curl_handle);


		$file=fopen($filename.'Response.xml',"w+");
		fwrite($file, $result);
		fclose($file);
		
		 echo $result;

 	 	 
?>

<?php 
  		
	 
 $header[] = "Content-type: text/xml"; 

// Target URL 
 $sendTo = $url; 

// Post Data 
 $post = data_string; 

// Create CURL Connection 
 $ch = curl_init(); 
 curl_setopt($ch, CURLOPT_USERAGENT, 'XtraDoh xAgent'); 
 curl_setopt($ch, CURLOPT_URL, $sendTo); 
 curl_setopt($ch, CURLOPT_TIMEOUT, 900); 
 curl_setopt($ch, CURLOPT_CONNECTIONTIMEOUT, 30); 
 curl_setopt($ch, CURLOPT_FAILONERROR, false); 
 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); 
 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); 
 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); 
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
 curl_setopt($ch, CURLOPT_HTTPHEADER, $header); 
 curl_setopt($ch, CURLOPT_POST, true); 
 curl_setopt($ch, CURLOPT_POSTFIELDS, $post); 
 $result1 = curl_exec ($ch) or die ("There has been a CURL_EXEC error");
 echo $result1;
?>

Answer : Curl API , XML parsing problem ?

Here's a set of files that I created for a similar question.  The final page generates an SQL string to put the data in a MySQL database but simply displays the info.
Random Solutions  
 
programming4us programming4us