domxml_new_doc("1.0"); werkt niet in php 5
nou wil ik met php een dir uitlezen dit werkt perfect met php 4 maar in 5 gaat het niet krijg ik de fout:
fatal error: Call to undefined function domxml_new_doc() in /storage/mijndomein/users/044523/public/sites/www.raymondbedum.nl/amfphp/services/fileManager.php on line 218
het script
Code (php)
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?
function getDirectory($directory) {
//$directory = "".$directory;
function getFiles($directory) {
// Try to open the directory
if($dir = opendir($directory)) {
// Create an array for all files found
$tmp = Array();
// Add the files
while($file = readdir($dir)) {
$fileType = filetype($directory . $file);
// Make sure the file exists
if($file != "." && $file != ".." && $file[0] != '.') {
// If it's a directiry, list all files within it
if(is_dir($directory . "/" . $file)) {
array_push($tmp, $directory . "/" . $file);
$tmp2 = getFiles($directory . "/" . $file);
if(is_array($tmp2)) {
$tmp = array_merge($tmp, $tmp2);
}
}
}
}
// Finish off the function
closedir($dir);
return $tmp;
}
}
$arr = getFiles($directory);
$doc = domxml_new_doc("1.0");
$root = $doc->create_element("Direcory");
$root->set_attribute("name", basename($directory));
$root->set_attribute("path", $directory);
$root->set_attribute("level", "0");
for ($i=0; $i<count($arr);$i++) {
//$name = ;
$newpath = str_replace ($directory."/", "", $arr[$i]);
$level = explode("/",$newpath);
$lvl = count($level);
$item[basename($arr[$i])] = $doc->create_element("Item");
$item[basename($arr[$i])]->set_attribute("name", basename($arr[$i]));
$item[basename($arr[$i])]->set_attribute("path", $arr[$i]);
$item[basename($arr[$i])]->set_attribute("level", $lvl);
if ($lvl < 2) {
$newnode = $root->append_child($item[basename($arr[$i])]);
} else {
//$parentname = ;
$parentpath = explode("/",dirname($arr[$i]));
$parentname = $parentpath[count($parentpath)-1];
$node = $item[$parentname];
$newnode = $node->append_child($item[basename($arr[$i])]);
}
}
$newnode = $doc->append_child($root);
$xmlfile = $doc->dump_mem( false, 'UTF-8' );
return $xmlfile;
} // einde function;
?>
function getDirectory($directory) {
//$directory = "".$directory;
function getFiles($directory) {
// Try to open the directory
if($dir = opendir($directory)) {
// Create an array for all files found
$tmp = Array();
// Add the files
while($file = readdir($dir)) {
$fileType = filetype($directory . $file);
// Make sure the file exists
if($file != "." && $file != ".." && $file[0] != '.') {
// If it's a directiry, list all files within it
if(is_dir($directory . "/" . $file)) {
array_push($tmp, $directory . "/" . $file);
$tmp2 = getFiles($directory . "/" . $file);
if(is_array($tmp2)) {
$tmp = array_merge($tmp, $tmp2);
}
}
}
}
// Finish off the function
closedir($dir);
return $tmp;
}
}
$arr = getFiles($directory);
$doc = domxml_new_doc("1.0");
$root = $doc->create_element("Direcory");
$root->set_attribute("name", basename($directory));
$root->set_attribute("path", $directory);
$root->set_attribute("level", "0");
for ($i=0; $i<count($arr);$i++) {
//$name = ;
$newpath = str_replace ($directory."/", "", $arr[$i]);
$level = explode("/",$newpath);
$lvl = count($level);
$item[basename($arr[$i])] = $doc->create_element("Item");
$item[basename($arr[$i])]->set_attribute("name", basename($arr[$i]));
$item[basename($arr[$i])]->set_attribute("path", $arr[$i]);
$item[basename($arr[$i])]->set_attribute("level", $lvl);
if ($lvl < 2) {
$newnode = $root->append_child($item[basename($arr[$i])]);
} else {
//$parentname = ;
$parentpath = explode("/",dirname($arr[$i]));
$parentname = $parentpath[count($parentpath)-1];
$node = $item[$parentname];
$newnode = $node->append_child($item[basename($arr[$i])]);
}
}
$newnode = $doc->append_child($root);
$xmlfile = $doc->dump_mem( false, 'UTF-8' );
return $xmlfile;
} // einde function;
?>
Gewijzigd op 01/01/1970 01:00:00 door Raymond
gebruiken, omdat xml ook zo begint.
Je moet dus gewoon:
gebruiken.