michaelh613 Posted April 3, 2008 Share Posted April 3, 2008 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.