-1
HI我有充滿圖像的文件夾被讀爲xml文件。 我想按照日期的子元素對它們進行分組。基於子元素值的分組結果
圖片格式:
entry_212_CA60CTF_2014-10-30_12-14-57.jpg
XML文檔:
<?xml version="1.0"?>
<Incidents xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Count="3" Date="2014-10-30" Time="12:14:57" FileName="2014-10-30_dones_Hillsborough_Leisure_Centre.xml">
<Incident>
<EntryTime>2014-08-16T08:54:12</EntryTime>// want to group by this element
<ExitTime>2014-08-16T17:03:51</ExitTime>
</Incident>
php文件:
if(file_exists($xmlFullFilename)) {
$xmlDoc = new DomDocument();
$xmlDoc->load($xmlFullFilename);
$tmp = $xmlDoc->getElementsByTagName("Incidents");
$root = $tmp->item(0);
}
我想組同日的所有EntryTime到一個XML文件中。該xml文件應該只包含第16個日期。
eg:<EntryTime>2014-08-16T08:46:17</EntryTime>...
$tmp = split(" ", $entryTime);
$dateString = $tmp[0] . "T" . $tmp[1];
$entryTimeNode = $xmlDoc->createElement("EntryTime", $dateString);