首页 > 解决方案 > 删除第一行并用php处理xml文件

问题描述

我在 xml 文件中有一个时间戳,我需要跳过第一行中存在的时间戳并使用 PHP 处理 xml 文件。下面是我的 XML 文件的示例。

2020-03-31T00:00:00-0500
<list>
    <listing>
        <ad_id>20624163</ad_id>
        <date_created>01-Apr-18</date_created>
        <price>$465,000</price>
     </listing>   
</list>  
<list>
    <listing>
        <ad_id>20624657</ad_id>
        <date_created>27-Apr-18</date_created>
        <price>$446,000</price>
     </listing>   
</list>     

下面是我试图处理 XML 文件的函数。

  function namespacedXMLToArray($xmlData) {
    return json_decode(json_encode(simplexml_load_string($xmlData)), true);
  }

无论如何我可以跳过第一行的时间戳吗?

标签: phpxml

解决方案


推荐阅读