-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxml.php
70 lines (63 loc) · 1.35 KB
/
xml.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
65
66
67
68
69
70
<pre><?php
//
// add attributes implementation
// ['@attr_name'] => 'attr_value'
//
include_once 'php/class/XML.php'; $XML = new XML();
function parse($xml, $fp, $tagname='')
{
foreach($xml->tagChildren as $tc)
{
if($tc->tagData)
{
ob_start();
echo "\n$tagname/".$tc->tagName."\n";
echo $tc->tagData."\n";
$txt = ob_get_clean();
fwrite($fp, $txt, strlen($txt));
}
if(is_array($tc->tagChildren)) { parse($tc, $fp, "$tagname/".$tc->tagName); }
}
}
$exceptions = array
(
'dirs' => array
(
'xml/lang/en/company',
'xml/lang/en/model',
'xml/lang/en/user'
),
'files' => array()
);
function scan($dir, $fp)
{
$dh = opendir($dir);
while($file=readdir($dh))
{
if($file!='.' && $file!='..')
{
$ext = substr($file, strrpos($file,'.')+1);
if(is_file("$dir/$file") && $ext=='xml')
{
if(!in_array("$dir/$file", $GLOBALS['exceptions']['files']))
{
ob_start();
echo "\n\n";
for($i=0; $i<strlen("$dir/$file"); $i++) { echo '='; } echo "\n";
echo "$dir/$file\n";
$txt = ob_get_clean();
fwrite($fp, $txt, strlen($txt));
$xml = $GLOBALS['XML']->parse("$dir/$file");
parse($xml, $fp);
}
}
else if(is_dir("$dir/$file"))
{
if(!in_array("$dir/$file", $GLOBALS['exceptions']['dirs'])) { scan("$dir/$file", $fp); }
}
}
}
}
$fp = fopen('xml.txt', 'w');
scan('xml', $fp);
?></pre>