【 tulaoshi.com - Web开发 】
example2.php
?php
include_once("XML/sql2xml.php");
$sql2xmlclass = new xml_sql2xml("mysql://username:password@localhost/xmltest");
$xmlstring = $sql2xmlclass-getxml("select * from bands left join albums on bands.id = bandsID");
?
输出结果
$xmlstring = '
?xml version="1.0"?
root
result
row
id1/id
nameThe Blabbers/name
birth_year1998/birth_year
birth_placeLondon/birth_place
genreRock'n'Roll/genre
row
id1/id
bandsID1/bandsID
titleBlaBla/title
year1998/year
commentTheir first one/comment
/row
row
id2/id
bandsID1/bandsID
titleMore Talks/title
year2000/year
commentThe second one/comment
/row
/row
row
id2/id
nameOnly Stupids/name
birth_year1997/birth_year
birth_placeNew York/birth_place
genreHip Hop/genre
row
id3/id
bandsID2/bandsID
titleAll your base.../title
year1999/year
commentThe Classic/comment
/row
/row
/result
/root
'