我的代码:
$go = mysql_query($sql);
$fetch = mysql_fetch_array($go);
$return = Array($fetch[0],$fetch[1],$fetch[2]);
$results = Array(
'body' => Array (
'entry' => Array (
'title' => $return[0],
'image' => $return[1],
'caption' => $return[2]
)
)
);
XML 输出:
此 XML 文件似乎没有任何与之关联的样式信息。文档树如下所示。
<callback xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="schema.xsd">
<body>
<entry>
<title>REHEARSAL DINNER IN SEATTLE, WA</title>
<image>images/portfolio_entries/default.png</image>
<caption>A wonderful in home event for 27 people.</caption>
</entry>
</body>
我希望它遍历查询中的所有行,并且 xml 输出看起来像这样:
<callback xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="schema.xsd">
<body>
<entry>
<title>REHEARSAL DINNER IN SEATTLE, WA</title>
<image>images/portfolio_entries/default.png</image>
<caption>A wonderful in home event for 27 people.</caption>
</entry>
<entry>
<title>BLAH NUMBER TWO</title>
<image>images/portfolio_entries/default2.png</image>
<caption>Blah blah info about number two.</caption>
</entry>
<entry>
<title>BLAH NUMBER THREE</title>
<image>images/portfolio_entries/default3.png</image>
<caption>blah blah info about number three.</caption>
</entry>
</body>
</callback>