【问题标题】:XML clean up using PHP使用 PHP 清理 XML
【发布时间】:2011-07-19 09:55:46
【问题描述】:

我有脏的 .out 文件,我正在将其转换为 xml。 我正在使用 php 对其进行清理,然后进行转换。我有这个问题。所有 URL 都经过编码,我需要它是正常的解码格式。

<article type="video" enterID="33">
<addedDate>2010-12-02 16:40:26</addedDate>
<thumbnail>http://eyops.com/sdfgsefgefsoio81f8b35.jpg</thumbnail>
<asset href="http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DBu927_ul_X0" addedDate="2010-12-02 16:40:23">
<duration>1500</duration>
</asset>
</article>

如何从标签中获取 href,对其进行解码,然后将输出写入 xml 文件?

【问题讨论】:

标签: php xml parsing tags file-io


【解决方案1】:

使用 dom 解析你的 xml,getAttribute('href') 用​​于特定节点,创建解码当前链接的新链接,并使用新链接设置属性。

之后,保存您的编辑。

http://www.w3schools.com/dom/met_element_getattribute.asp

http://www.w3schools.com/Dom/met_element_setattribute.asp

【讨论】:

    【解决方案2】:

    使用 urldecode:http://php.net/manual/en/function.urldecode.php 进行转换。您如何在输出中提取和替换取决于您使用的工具。

    【讨论】:

      猜你喜欢
      • 2012-12-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-22
      • 2012-05-31
      • 1970-01-01
      • 2016-09-28
      • 1970-01-01
      相关资源
      最近更新 更多