代码拉取完成,页面将自动刷新
<?php
function make1node_lable($nd, $f) {
static $gtmp = 0;
$str = $nd->nodeName . $gtmp . " [\n";
$gtmp += 1;
$str .= " label = \"{" . $nd->nodeName . "\n";
$str .= " |+ name : string" . "\n";
$str .= " \\l+ age : int\n";
$str .= " \\l|+ die() : void\\l\n";
$str .= " }\"";
$str .= "]\n\n";
fwrite($f, $str);
}
function make_dot_file_title($f) {
$str = "digraph graphname {\n";
$str .= " nodesep=2.5;\n";
$str .= " node [shape = record];\n";
fwrite($f, $str);
}
function gen_dot_file($gccxml_path) {
if (!file_exists($gccxml_path)) {
print($gccxml_path . " do not exists.");
return;
}
$xmlDoc = new DOMDocument();
$xmlDoc->load($gccxml_path);
$x = $xmlDoc->documentElement;
$dotfile = fopen($gccxml_path . ".dot", "w") or die("Unable to open file!" . $gccxml_path . ".dot");
make_dot_file_title($dotfile);
foreach ($x->childNodes AS $item) {
if(!isset($item->nodeName)) {
continue;
}
if('#text' == $item->nodeName) {
continue;
}
//print "<tagName>:" . $item->nodeName . "\n";
make1node_lable($item, $dotfile);
foreach($item->attributes as $b) {
//echo " <attr>:" . $b->nodeName . ":" . $b->nodeValue . "\n";
}
foreach($item->childNodes as $ic) {
if(!isset($ic->nodeName)) {
continue;
}
if('#text' == $ic->nodeName) {
continue;
}
//print " <childTag>:" . $ic->nodeName . "\n";
foreach($ic->attributes as $ica) {
//echo " <attr>:" . $ica->nodeName . ":" . $ica->nodeValue . "\n";
}
}
}
fwrite($dotfile, "}\n");
fclose($dotfile);
}
//gen_dot_file("upload/demo.xml");
?>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。