Page 2 of 2

Re: XML not appearing correctly.

Posted: Mon Mar 17, 2008 8:49 pm
by michaelh613
As I study up more I've learned there is a command to allow me to echo out xml. So I've taken a snippet of my code to try an see what am getting

Code: Select all

 
<?php    
     /**      * Define POST URL and also payload     */     
     
      require 'createxml.php';
      $xmlResult = simplexml_load_string($result);
      echo "xmlresult is ". $xmlResult->asXML();
      die();
?>
 
the script creating the xml is the same as already posted above.

The screen show the following output

Invalid at the top level of the document. Error processing resource 'myurl'. Line 1, Pos...

xmlresult is <?xml version="1.0"?>

Which is obviously not the full xml I am looking for. However when I go to view source I get

xmlresult is <?xml version="1.0"?>
<REQUEST_GROUP MISMOVersionID="2.1">
<REQUEST LoginAccountIdentifier="testuser">
<KEY _NAME="MemberID" _Value="100"/>
<REQUEST_DATA>
<CREDIT_REQUEST MISMOVersionID="2.1">
<CREDIT_REQUEST_DATA CreditRequestID="CRReq0001" BorrowerID="BorRec0001" CreditReportRequestActionType="Submit" CreditReportType="Consumer" CreditRequestType="Individual">
<CREDIT_REPOSITORY_INCLUDED _EquifaxIndicator="N" _ExperianIndicator="Y" _TransUnionIndicator="N"/>
</CREDIT_REQUEST_DATA>
<LOAN_APPLICATION>
<BORROWER BorrowerID="BorRec0001" _FirstName="EVPAULA" _MiddleName="" _LastName="Consumer" _SSN="376988419">
<_RESIDENCE _StreetAddress="10655 Birch St" _City="Burbank" _State="Ca" _PostalCode="20906"/>
</BORROWER>
</LOAN_APPLICATION>
</CREDIT_REQUEST>
</REQUEST_DATA>
</REQUEST>
</REQUEST_GROUP>

There must be something wrong with this xml. It actually matches up with what I have in my specs from a third party. So I think they must have something wrong. I'm hoping someone can lead me to the problem so I can go to their support people and get the correct format. As we all know tech support often needs alot of help I'm thinking if I can figure this out I will have my answer.

Re: Variable values not appearing

Posted: Mon Mar 17, 2008 9:11 pm
by michaelh613
I've just resolved my issue being able to echo it to the screen so now I just need to get curl to properly post it. Proper code to echo it to the screen (I'm putting this for anyone who finds this discussion through a search is

Code: Select all

 
<?php    
     /**      * Define POST URL and also payload     */     
     
      require 'createxml.php';
      $xmlResult = simplexml_load_string($result);
      echo $xmlResult->asXML();
      die(); 
?>
 
Works like a charm. So now I just need to send it to a url with curl

Re: Variable values not appearing

Posted: Mon Mar 17, 2008 9:44 pm
by RobertGonzalez
Can you output whatever you are sending to cURL to see if it is getting the right data?

Re: Variable values not appearing

Posted: Mon Mar 17, 2008 10:15 pm
by michaelh613
Everah wrote:Can you output whatever you are sending to cURL to see if it is getting the right data?
I've outputed my data and verified I can print it to a browsere correctly using

Code: Select all

 
$xmlResult = simplexml_load_string($result);
 echo $xmlResult->asXML();
 

I realizd I was missing CURLOPT_POST command in my code.

I've been able to use the following script just to post a normal form type data to a URL

Code: Select all

 
<?php
$ch= curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.yourcomputerconsultant.com/test_data.php");      
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "Hello=World$Foo=Bar&Baz=Wombat"); 
curl_exec($ch);
curl_close($ch);
?>
 
It doesn't work with xml data. So I believe I just need to figure out how to change this script to send xml data as a post rather than paired
variable value data as seen above.

my code with xml

Code: Select all

 
<?php
require 'createxml.php';
$xmlResult = simplexml_load_string($result);
$ch= curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.yourcomputerconsultant.com/test_data.php");      
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlResult);
//curl_setopt($ch, CURLOPT_POSTFIELDS, "Hello=World$Foo=Bar&Baz=Wombat"); 
curl_exec($ch);
curl_close($ch);
?>
 

Re: Variable values not appearing

Posted: Tue Mar 18, 2008 10:37 am
by michaelh613
As the issue has changed from creating a xml form to how to post a dom object using curl I have created this issue as a new topic to make it easier to be searched on over at viewtopic.php?f=1&t=80233&p=449522#p449522

I appreciate any help people give me.