CodeIgniter : Create xml file and send it via FTP

I'm trying to create an XML file and tried to search on Google to see if there is a tutorial for me to follow on how to convert data to XML. I need to create the XML file itself and send it to my server using FTP.

$dom = xml_dom();
$lead = xml_add_child($dom, 'Leads');
    $leadData = xml_add_child($lead, 'LeadData');
    xml_add_child($leadData, 'CompanyName', $CompanyName);
    xml_add_child($leadData, 'IndustryType', $IndustryType);
    xml_add_child($leadData, 'ContactFirstName', $ContactFirstName);
    xml_add_child($leadData, 'ContactLastName', $ContactLastName);
    xml_add_child($leadData, 'ContactTitle', $ContactTitle);
    xml_add_child($leadData, 'Phone', $Phone);
    xml_add_child($leadData, 'Email', $Email);
    xml_add_child($leadData, 'OpportunityAmount', $OpportunityAmount);
    xml_add_child($leadData, 'LeadNotes', $LeadNotes);
    xml_add_child($leadData, 'SalesRep', $SalesRep);
    xml_add_child($leadData, 'Status', $Status);
    xml_add_child($leadData, 'Category', $Category);
    xml_add_child($leadData, 'Source', $Source);
    xml_add_child($leadData, 'AnnualRevenue', $AnnualRevenue);
    xml_add_child($leadData, 'BillingAddressLine1', $BillingAddressLine1);
    xml_add_child($leadData, 'BillingAddressLine2', '');
    xml_add_child($leadData, 'BillingAddressLine3', '');
    xml_add_child($leadData, 'City', $City);
    xml_add_child($leadData, 'State', $State);
    xml_add_child($leadData, 'Zip', $Zip);
    xml_add_child($leadData, 'BillingPhone', $BillingPhone);
    xml_add_child($leadData, 'AppointmentDate', $AppointmentDate);
    xml_add_child($leadData, 'AppointmentFromTime', $AppointmentFromTime);
    xml_add_child($leadData, 'AppointmentToTime', $AppointmentToTime);
    xml_add_child($leadData, 'AppointmentDescription',$AppointmentDescription);

I believe that the code above is correct, right?

1 answer