Search code examples
phpxmldomdocument

php XML create <?adf version="1.0"?> tag


I am trying to come up an adf xml file to post to a crm.

so far I have been able to create this

<?xml version="1.0" encoding="UTF-8"?>

<adf version="1.0">

<prospect>

but need to create this

<?xml version="1.0" encoding="UTF-8" ?>

  <?adf version="1.0"?>

      <adf>

      <prospect>

I cant seem to find a way to create the tag. Need help.

I am trying to come up with and adf xml file using php dom the file should look like this

I m trying to come up with an adf xml document using the dom in php eg

  <?ADF VERSION="1.0"?> 
    <adf> 
      <prospect> 
        <id sequence="uniqueLeadId" source="name of promotion"></id> 
        <requestdate>2008-06-25T8:47:50</requestdate> 
        <vehicle interest="buy" status="used"> 
          <vin>2G4WF52L6S1472882</vin> 
          <year>1995</year> 
          <make>BUICK</make> 
          <model>Regal</model> 
          <stock>12886</stock> 
        </vehicle> 
        <customer> 
          <contact> 
          <name part="first" type="individual">Johnny</name> 
          <name part="last" type="individual">Customer</name> 
          <email>johnny@customer.com</email> 
          <phone type="home">857-485-7485</phone> 
          <phone type="work">867-586-7584</phone> 
          <phone type="mobile">979-685-9685</phone> 
        </contact> 
        <comments>What is your best price?</comments> 
      </customer> 
      <vendor> 
        <contact> 
            <name part="full">Name of lead provider or web-site</name> 
            <email>johnny@vendor.com</email> 
            <phone type="business">857-485-7485</phone> 
        </contact> 
      </vendor> 
    </prospect> 
</adf>

I am able to create the file only problem is creating the adf declaration on the xml. I am only able to create an element and assign an attribute to it eg

$root = $xmlDoc->appendChild($xmlDoc->createElement("adf"));

$root->setAttribute("version","1.0");

Solution

  • $pi = $xmlDoc->createProcessingInstruction('adf', 'version="1.0"');