所以我发现了这个将mysql查询转换为XML页面的强大功能,它看起来就像我需要的那样.唯一的问题是它使用了mysql,但是不再支持它,结果发现其中一个函数不在mysqli中.有谁知道mysql_field_name的替代品?
这是我找到的功能
function sqlToXml($queryResult, $rootElementName, $childElementName)
{
$xmlData = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n";
$xmlData .= "<" . $rootElementName . ">";
while($record = mysql_fetch_object($queryResult))
{
/* Create the first child element */
$xmlData .= "<" . $childElementName . ">";
for ($i = 0; $i < mysql_num_fields($queryResult); $i++)
{
$fieldName = mysql_field_name($queryResult, $i);
/* The child will take the name of the table column */
$xmlData .= "<" . $fieldName . ">";
/* We set empty columns with NULL, or you could …Run Code Online (Sandbox Code Playgroud)