【发布时间】:2017-01-11 14:22:17
【问题描述】:
我正在尝试创建一个 XML 文件,并尝试在 Google 上搜索以查看是否有关于如何将数据转换为 XML 的教程供我学习。我需要自己创建 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);
我相信上面的代码是正确的,对吧?
【问题讨论】:
-
我看不到您尝试将其发送到 FTP 服务器的代码。请注意,我们需要您的代码才能为您提供帮助。我们不是来为您编写代码的……
-
@arkascha 是的,上面的代码只是用于将数据转换为 xml 格式,我要问的是如何将转换后的数据生成为 .xml
-
您的意思是如何将其保存到文件中?嗯,用php的文件操作函数,我就说……
-
或者你已经使用的类中实现的文件处理方法,也就是。在这种情况下:php.net/manual/de/domdocument.savehtmlfile.php
-
将这些方法与 codeigniter 一起使用是否安全?
标签: php xml codeigniter ftp