上传到 Drupal 页面后,我需要修改 xml 文件。为此,我使用规则模块对文件进行一些更改并将其保存在服务器上的新位置。这很好用,但在保存的新文件中有一些 <@attribute>-标签,它们不应该存在。我要做的是:
$fileUri = $xml_file->uri;
$xmlDaten = simplexml_load_file($fileUri);
foreach ($xmlDaten->xpath('//Reference') as $reference) {
dpm($reference);
}
$xmlDaten->asXML('sites/example.de/files/xml/xml_import.xml');
我不做任何操作,只使用 Drupals 开发模块循环和显示参考节点,但保存的文件包含损坏的数据:
<Reference ID="72c24cb5-c422-41c8-9047-cd43536d0f1f" ReferenceType="CollectedWorks" CreatedBy="i" CreatedOn="2012-11-26T16:15:45" ModifiedBy="i" ModifiedOn="2013-02-26T13:45:38" SequenceNumber="28160">
<Authors>b332174e-9007-4e30-9da6-f79e5bb6bb08</Authors>
<CitationKeyUpdateType>Automatic</CitationKeyUpdateType>
<PlaceOfPublication>Paris</PlaceOfPublication>
<Publishers>a38d2bf6-aba5-49de-8783-291c0bc58165</Publishers>
<Subtitle>Item Caii Iulii Solini Polyhistor ex veteribvs libris emendatvs</Subtitle>
<Title>Cl. Salmasii Plinianae exercitationes In Caii Iulii Solini Polyhistora</Title>
<Year>1629</Year>
<@attributes/></Reference>
这是来自原始文件:
<Reference ID="72c24cb5-c422-41c8-9047-cd43536d0f1f" ReferenceType="CollectedWorks" CreatedBy="i" CreatedOn="2012-11-26T16:15:45" ModifiedBy="i" ModifiedOn="2013-02-26T13:45:38" SequenceNumber="28160">
<Authors>b332174e-9007-4e30-9da6-f79e5bb6bb08</Authors>
<CitationKeyUpdateType>Automatic</CitationKeyUpdateType>
<PlaceOfPublication>Paris</PlaceOfPublication>
<Publishers>a38d2bf6-aba5-49de-8783-291c0bc58165</Publishers>
<Subtitle>Item Caii Iulii Solini Polyhistor ex veteribvs libris emendatvs</Subtitle>
<Title>Cl. Salmasii Plinianae exercitationes In Caii Iulii Solini Polyhistora</Title>
<Year>1629</Year>
</Reference>
知道 <@attributes/> 是如何进入数据的吗?