【问题标题】:Json to Array to XML[Php]Json 到数组到 XML [Php]
【发布时间】:2013-10-05 18:42:32
【问题描述】:

我正在尝试在 php 中使用 jsonarray 转换为 xml

jsonarray 工作正常,但是当我尝试将 array 转换为 xml 时,我不断收到错误消息。

Call to undefined function array_to_xml()

这是json

{"host":"127.0.0.1","username":"root","password":"something","dbname":"something","table":"something"}

Json 到`数组

$json = json_decode(file_get_contents('something.json'), true);
$info = array(
$json['host'],
$json['username'],
$json['password'],
$json['dbname'],
);    

数组到xml

simplexml_load_string(array_to_xml($json, new SimpleXMLElement('<connection/>'))->asXML()) or die("can't read");

【问题讨论】:

  • 你是在使用一些库还是没有名为array_to_xml的内置php函数的东西
  • 不是真的,我明白了。那么有没有办法让我完成这项工作?
  • 你可以试试看this page他们使用DOM接口来创建xml

标签: php xml json


【解决方案1】:

也许是因为没有名为 array_to_xml() 的函数?你必须先定义它。

【讨论】:

  • 应该是评论吧,真的。
  • 抱歉,声望不够。无论如何我都想帮忙。
猜你喜欢
  • 2010-12-04
  • 2012-03-21
  • 2012-08-22
  • 2011-03-26
  • 1970-01-01
  • 1970-01-01
  • 2019-03-28
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多