queryxml.sh
#!/sbin/php -q
<?php
//eg: ./queryxml.sh /home/etc/application/config/sys_para.xml paraName
$fileName = $argv[1];// /home/etc/application/config/sys_para.xml ;
$setName = $argv[2];// 'paraName'
if(empty($fileName)){
echo 'fileName is Empty';
exit;
}
if(empty($setName)){
echo 'setName is Empty';
exit;
}
$LIST_TAG = 'Para';
$NAME_TAG = 'Name';
$VALUE_TAG = 'Value';
$doc = new DOMDocument();
$doc->load($fileName);
$paras = $doc->getElementsByTagName($LIST_TAG);
foreach($paras as $para){
$name = $para->getElementsByTagName($NAME_TAG)->item(0)->nodeValue;
$value = $para->getElementsByTagName($VALUE_TAG)->item(0)->nodeValue;
if($name == $setName){
//$para->getElementsByTagName($VALUE_TAG)->item(0)->nodeValue = $setValue;
//echo $name."-".$value."==>".$setValue;
echo $value;
break;
}
}
?>
网友评论