【问题标题】:Change encoding of an xml file in php在php中更改xml文件的编码
【发布时间】:2016-01-11 07:56:15
【问题描述】:

我打开了一个等待查询的服务器。 当我发送查询时,服务器将回答它并将结果保存在 xml 文件中。 问题是,我不能正确使用这个 xml,因为现在在 xml 的第一行写了:

xml 版本="1.0 编码="utf-8"

如果我在编辑器中将其更改为:

xml 版本="1.0 编码="iso-8859-1

比它工作正常。 但不是使用编辑器和我的手,我想要 php 来做吗? 谢谢

【问题讨论】:

  • 请提供您的代码。
  • 其实我看不到代码,因为是别人写的。我使用 exec("curl "localhost:8888/?q=queryToSearch" > "patch/to/file/result.xml" ) 生成了 xml,但它是在 utf-8 编码中生成的,我想在 iso-8859-1 中更改它
  • 为什么不用 str_replace(str,'utf-8','iso-8859-1') ?
  • thx man :) 工作,不明白为什么我没有想到 fixed

标签: php xml encoding utf-8 iso-8859-1


【解决方案1】:

只是为了结束这个问题: 我在xml文件中使用了str_replace(str,'utf-8','iso-8859-1'),它帮助我以正确的方式打开了xml文件。 谢谢你

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多