Page 1 of 1

Parsing XML Document

Posted: Mon Dec 06, 2004 7:13 am
by munnan
Hello all,
I am struck with a XML document parsing.
Following URL contain the Xml functions.
http://195.57.250.36/barceloDS/interface/xml
The method through which I am trying to access xml function in PHP is given below. But I am unable to get these functions to get data in PHP.

Code: Select all

<?php
// includes nusoap classes
 require('nusoap.php');

  $l_aParam="<?xml version='1.0' encoding='ISO-8859-1'?>
	<barceloDS_requests>
	<request type='availability list' id='1'>
	  <language_code>ING</language_code>
	  <agency>
		<primary>78</primary>
		<secondary>88</secondary>
		<detail>888</detail>
		<branch>1</branch>
	  </agency>
	  <contract></contract>
	  <check_in_date>20051201</check_in_date>
	  <check_out_date>20051207</check_out_date>
	  <location>
		<destination_code>PMI</destination_code>
		<zone_code></zone_code>
	  </location>
	  <establishment>
		<code></code>
		<category></category>
	  </establishment>
	  <board_type_code></board_type_code>
	  <occupancy>
		<adults>2</adults>
		<children>0</children>
		<rooms>1</rooms>
	  </occupancy>
	</request>
	</barceloDS_requests>";
	
  //print($l_aParam);
  
   // set parameters and create client

  $l_oClient  = new soapclient(‘[url]http://195.57.250.36/barceloDS/interface/xml’[/url]);

  // call a webmethod 
  $l_stResult = $l_oClient->call('availability',$l_aParam);
 /*”I think the problem area is this”*/
  
  print_r($l_stResult);
  
  if ($l_oClient->getError()) {
	  
   	echo("Error Found :".$l_oClient->getError());
  }
  else{
  	echo("No Error Found");
  }
 ?>

Following is the sample code in ASP that company had provided me that is working fine.

<%
Dim xml

xml = "xml=<?xml version='1.0' encoding='ISO-8859-1'?>" + _
"<barceloDS_requests>" + _

"<request type='availability list' id='1'>" + _
" <language_code>ING</language_code>" + _
" <agency>" + _
" <primary>888</primary>" + _
" <secondary>88</secondary>" + _
" <detail>888</detail>" + _
" <branch>1</branch>" + _
" </agency>" + _
" <contract></contract>" + _
" <check_in_date>20041201</check_in_date>" + _
" <check_out_date>20041207</check_out_date>" + _
" <location>" + _
" <destination_code>PMI</destination_code>" + _
" <zone_code></zone_code>" + _
" </location>" + _
" <establishment>" + _
" <code></code>" + _
" <category></category>" + _
" </establishment>" + _
" <board_type_code></board_type_code>" + _
" <occupancy>" + _
" <adults>2</adults>" + _
" <children>0</children>" + _
" <rooms>1</rooms>" + _
" </occupancy>" + _
"</request>" + _

"</barceloDS_requests>"

'==================================
'Response.Write xml
'Response.End
'==================================


Dim xmlHTTP, URLPath

Set xmlHTTP = Server.Createobject("MSXML2.ServerXMLHTTP")

' url test server
URLPath = "http:// 194.224.184.162/barceloDS/interface/xml"

xmlHTTP.open "POST", URLPath, False
xmlHTTP.SetRequestHeader "Content-type","application/x-www-form-urlencoded"

xmlHTTP.send(xml)

'strXMLOut = xmlHTTP.responseText
strXMLOut = xmlHTTP.ResponseXML.xml

'==================================
'Response.Write(strXMLOut)
'Response.End
'==================================

Dim xmlDoc

Set xmlDoc = Server.CreateObject("Msxml2.DOMDocument")
xmlDoc.async = False
xmlDoc.load ("strXMLOut")
xmlDoc.validate

If xmlDoc.parseError.errorCode <> 0 Then
Response.Write("A parse error occurred.<br>")
Response.Write("Error Code is: ")
Response.Write(xmlDoc.parseError.errorCode)
Response.Write("<br>")
Response.Write("The reason is: ")
Response.Write(xmlDoc.parseError.reason)
Response.Write("<br>")
Response.Write("Error in Line No.: ")
Response.Write(xmlDoc.parseError.Line)
Response.Write("<br>")
Response.Write("Position: ")
Response.Write(xmlDoc.parseError.linepos)
Response.Write("<br>")
Response.Write("Error in URL: ")
Response.Write(xmlDoc.parseError.url)
Response.Write("<br>")
Response.End()

End If
%>





I am unable to retrieve data through my php script(that I have provided above) ,please help me out by telling the ways to retrieve data through this xml document.
Thanking you in anticipation,
Munnan