使用php生成特定格式的xml
嗨,我想创建一个php代码,生成下面给出的特定格式的xml。请帮我解决这个问题使用php生成特定格式的xml,php,xml,Php,Xml,嗨,我想创建一个php代码,生成下面给出的特定格式的xml。请帮我解决这个问题 <?xml version="1.0" encoding="utf-8"?> <order> <requisition> <dateofservice>2012-12-13</dateofservice> <labid>str1234</labid> <reqnotes_c
<?xml version="1.0" encoding="utf-8"?>
<order>
<requisition>
<dateofservice>2012-12-13</dateofservice>
<labid>str1234</labid>
<reqnotes_c>str1234</reqnotes_c>
<rptemail_c>str1234</rptemail_c>
<rptmethod_c>str1234</rptmethod_c>
<specimen_type_c>str1234</specimen_type_c>
<collectiontype_c>str1234</collectiontype_c>
</requisition>
<patient>
<firstname>str1234</firstname>
<lastname>str1234</lastname>
<dob>2012-12-13</dob>
<breed_c>str1234</breed_c>
<species>str1234</species>
<sex>s</sex>
<sterilization_c>str1234</sterilization_c>
</patient>
</order>
堆栈溢出不是代码编写服务。如果您有特定的问题,人们会帮助您,但我们不是来为您工作的。@蓝狐现在您能纠正我吗输入在哪里?输入文件是csv文件
while (($row = fgetcsv($inputFile)) !== FALSE){
$container = $doc->createElement('row');
foreach($headers as $i => $header) {
if(!empty($row[$i])) {
$child = $doc->createElement($header);
$child = $container->appendChild($child);
$value = $doc->createTextNode($row[$i]);
$value = $child->appendChild($value);
}
}
$root->appendChild($container);
}
$strxml = $doc->saveXML();