1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
function simplexml_append(SimpleXMLElement $parent, SimpleXMLElement $new_child){
$node1 = dom_import_simplexml($parent);
$dom_sxe = dom_import_simplexml($new_child);
$node2 = $node1->ownerDocument->importNode($dom_sxe, true);
$node1->appendChild($node2);
}
function _FillDataSet($serialisedDataSet,$tableName,$condition) {
$xmlDataSet = simplexml_load_string(trim($serialisedDataSet, " ?."));
$xmlDataSet->registerXPathNamespace('diffgr', 'urn:schemas-microsoft-com:xml-diffgram-v1');
$diffgr = $xmlDataSet->xpath('//diffgr:diffgram');
$NewDataSet = new SimpleXMLElement('<NewDataSet></NewDataSet>');
//$NewDataSet = $xmlDataSet->addChild('NewDataSet');
openDb();
$result = mysql_query("select * from ".$tableName) or die;
$j = 0;
while ($row = mysql_fetch_assoc($result)) {
$tableRow = $NewDataSet->addChild($tableName);
$tableRow->addAttribute('msdata:rowOrder',$j++,'urn:schemas-microsoft-com:xml-msdata');
$tableRow->addAttribute('diffgr:id', $tableName.$j,'urn:schemas-microsoft-com:xml-diffgram-v1');
$i=0;
while ($i < mysql_num_fields($result)) {
$meta = mysql_fetch_field($result, $i);
$tableRow->addChild($meta->name,$row[$meta->name]);
$i++;
}
}
simplexml_append($diffgr[0],$NewDataSet);
return $xmlDataSet->asXML();
} |
Partager