php返回数据

原本是读取xml文件 运行没错
xml格式
[code="xml"]<?xml version="1.0" encoding="UTF-8"?>


Dreamweaver MX 2004 Design Projects takes you through the process of creating four real-world case studies, enabling you to take your Dreamweaver skills to a new level.


[/code]
flex调用
[code="flex"]books = event.result.books.image;[/code]

现在换成php调用数据库读数据做不对。请教一下怎么做,最好能和读取xml的效果是一样的。
flex里是用ArrayCollection保存数据
[b]问题补充:[/b]
谢谢lhx222 的回答

我现在是想用php直接给flex返回一数组,包含多个image信息,并不生成xml。
最好php返回的数组和原来xml一样,这样可以不用该flex代码。

可以使用Jquery来读取:
[code="HTML"]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">



XML $("document").ready(function(){ $.ajax({ url: "books.xml",//xxx.php dataType: "xml", //这里注意的是应该加上这个 success: function(xml){ $(xml).find("books > image").each(function(){ var image = $(this); var imageContext = image.text(); var filename = image.attr('filename'); var title = image.attr('title'); var author = image.attr('author'); var category = image.attr('category'); var descContext = image.find("desc").text(); alert(imageContext); alert(filename); alert(author); alert(filename); alert(category); alert(descContext); }); } }); });



[/code]

books.xml文件:
[code="xml"]
<?xml version="1.0" encoding="utf-8"?>





Dreamweaver MX 2004 Design Projects takes you through the process of creating four real-world case studies, enabling you to take your Dreamweaver skills to a new level.




[/code]

15行代码
imageimageContext应为imageContext

那你先用PHP从数据库中读取数据,然后使用相关xml的组件将数据组装成一个xml文件(或xml格式的字符串流)返回给flex。这样应该可以吧。