doucang9673 2018-11-26 17:56
浏览 20

缺少XML的数据

something happening in my script and i cant figure out whats going on, basically i have a array of products, and with this array im populating the items in the foreach loop to a xml file, the problema is that in the first nodes appears empty data, and im sure that i dont have emmpty data in the array, i already tried just printing the data in plaintext and works fine, only when im looping and creating the xml file.

My script:
$xml = new SimpleXMLElement('<products/>');

for ($i = 0; $i <= sizeof($catalog); ++$i) {
    $track = $xml->addChild('product');
    $track->addChild('name', $i . $catalog[$i]["name"]);
    $track->addChild('brand', $catalog[$i]["brand"]);
}

Header('Content-type: text/xml');
print($xml->asXML());
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 请提供一个符合要求的网页链接。
    • ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”
    • ¥15 网络设备配置与管理这个该怎么弄
    • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
    • ¥20 西门子S7-Graph,S7-300,梯形图
    • ¥50 用易语言http 访问不了网页
    • ¥50 safari浏览器fetch提交数据后数据丢失问题
    • ¥15 matlab不知道怎么改,求解答!!
    • ¥15 永磁直线电机的电流环pi调不出来
    • ¥15 用stata实现聚类的代码