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

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.