简体   繁体   English

CodeIgniter:创建xml文件并通过FTP发送

[英]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. 我正在尝试创建XML文件,并试图在Google上进行搜索,以查看是否有教程供我参考,以了解如何将数据转换为XML。 I need to create the XML file itself and send it to my server using FTP. 我需要创建XML文件本身,并使用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? 我相信上面的代码是正确的,对吗?

You don't need to use codeigniter to do this. 您不需要使用codeigniter来执行此操作。 Codeigniter is a framework to make PHP coding easier/better, but you are still programming in PHP. Codeigniter是使PHP编码更容易/更好的框架,但是您仍在使用PHP进行编程。 Just read the documentation on the PHP website. 只需阅读PHP网站上的文档。 The steps are: 这些步骤是:

remember when creating files on a website that you need to consider if the operation can occur more than once at the same time. 请记住,在网站上创建文件时,您需要考虑该操作是否可以同时进行多次。 a way around this is to create a unique temporary directory to work from so there is no chance that two concurrent operations can conflict. 解决此问题的一种方法是创建一个唯一的临时目录进行工作,因此两个并发操作不会冲突。

Taking a step back, i would question why you are sending this as a file, and not running a RESTful server that can accept POST data. 退后一步,我会问为什么您将其作为文件发送,而不是运行可以接受POST数据的RESTful服务器。 If you want more information on a codeigniter implementation of REST, have a look at this link https://github.com/chriskacerguis/codeigniter-restserver . 如果您想了解有关REST的codeigniter实现的更多信息,请查看此链接https://github.com/chriskacerguis/codeigniter-restserver

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM