Jump to content

error creating xml document with simple xml


michaelh613

Recommended Posts

Here is my code

 


<?php
function createAuthenticateXML()
{

$dom = new DOMDocument('1.0');
//create root element <Request_group> and append it to the document
$RESPONSE_GROUP = $dom->appendChild($dom->createElement('RESPONSE_GROUP'));
$RESPONSE_GROUP->setAttribute('MISMOVersionID','2.1');

$RESPONSE=$RESPONSE_GROUP->appendChild($dom->createElement('RESPONSE'));
$KEY=$RESPONSE->appendChild($dom->createElement('KEY_Name'));
$KEY->setAttribute('_Name','MemberID');
$KEY->setAttribute('_Value','123123123');

$RESPONSE_DATA=$RESPONSE->appendChild($dom->createElement('RESPONSE_DATA'));

$CREDIT_RESPONSE=$RESPONSE_DATA->appendChild($dom->createElement('CREDIT_RESPONSE'));
$CREDIT_RESPONSE->setAttribute('CreditReportType','Status');

$STATUS=$RESPONSE->appendChild($dom->createElement('STATUS'));
$STATUS->setAttribute('_Condition','Success');
$STATUS->setAttribute('_Name','PresentConsumerValidity');

$dom -> formatOutput = true;
$result= $dom->saveXML();
return $result;
}

$xml = createAuthenticateXML();
echo $xml->asXML(); 
echo $xml;	
?>

 

I am receiving an error message

Fatal error: Call to a member function asXML() on a non-object in C:\Inetpub\Sites\test\createauthenticatexml.php on line 26

 

I have echo'd my results without using asXML and received the following output in view source

 

<?xml version="1.0"?>

<RESPONSE_GROUP MISMOVersionID="2.1">

  <RESPONSE>

    <KEY_Name MemberID="123123123"/>

    <RESPONSE_DATA>

      <CREDIT_RESPONSE CreditReportType="Status"/>

    </RESPONSE_DATA>

    <STATUS _Condition="Success" _Name="PresentConsumerValidity"/>

  </RESPONSE>

</RESPONSE_GROUP>

 

which appears to be a well formed xml

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.