问使用过pear库中的xml_tree类的朋友一个问题,谢谢
我把adodb里的数据集用xml_tree生成一个xml文件,使用insertChild函数,但是为什么生成的结点不是按照recordset中的顺序输出,而是倒的输出的
关键是我对insertChild中参数pos搞不清楚。哪位大哥帮看看
$tree = &new XML_Tree();
$root = $tree->addroot('Result');
$children = $tree->insertChild('Result',0,'Parent');
$num_fields = $recordset->FieldCount(); // Store number of fields
$children_pos = 0;
while ($row = $recordset->FetchRow()) // Store table row info
{
$children = $tree->insertChild('Result',1,'Children');
for ( $ct = 0; $ct < $num_fields; $ct++ ) //Traverse field names
{
$fld_all = $recordset->FetchField($ct);
if($fld_all->type == "blob")
{
$tree->insertChild('Result/Children',$ct,$fld_all->name,strtolower(mssql_guid_string(trim(($row[$ct])))));
}
else
{
$tree->insertChild('Result/Children',$ct,$fld_all->name,trim($row[$ct]));
}
}
$children_pos++;
}
$children = $tree->insertChild('Result/Parent',0,'GUID',$strGuid);
return $tree->dump(true);