-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_xml.php
46 lines (43 loc) · 1.14 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
<pre><?php
$dir = 'php/script/xml';
$dh = opendir($dir);
while($file=readdir($dh))
{
if(is_file("$dir/$file")) { include_once "$dir/$file"; }
}
$txt = file_get_contents('xml.txt');
$files = preg_split("/[\r\n]+=+[\r\n]+/", $txt, -1, PREG_SPLIT_NO_EMPTY);
foreach($files as $file)
{
$xml = xmlGenerateSchema();
$blocks = preg_split("/(\r\n){2}/", $file, -1, PREG_SPLIT_NO_EMPTY);
$name = $blocks[0];
var_dump($name);
array_splice($blocks, 0, 1);
foreach($blocks as $block)
{
$rows = preg_split("/[\r\n]/", $block, -1, PREG_SPLIT_NO_EMPTY);
$tag = $rows[0];
//var_dump($tag);
array_splice($rows, 0, 1);
$rows = join("\n", $rows);
//var_dump($rows);
$tagps = preg_split("/\//", $tag, -1, PREG_SPLIT_NO_EMPTY);
$tagstr = '[root]';
for($i=0; $i<count($tagps)-1; $i++)
{
$tagp = $tagps[$i];
$tagstrb = $tagstr;
$tagstr .= '['.$tagp.']';
if(!eval("return \$xml{$tagstr};"))
{
$tagxml = xmlGenerateTag($tagp, '', '');
eval("xmlInsertTag(\$tagxml, \$xml{$tagstrb});");
}
}
$tagxml = xmlGenerateTag($tagps[count($tagps)-1], '', $rows);
eval("xmlInsertTag(\$tagxml, \$xml{$tagstr});");
}
print_r($xml);
}
?></pre>