Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/253.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
通过php输出xml文件的某些字段_Php_Xml - Fatal编程技术网

通过php输出xml文件的某些字段

通过php输出xml文件的某些字段,php,xml,Php,Xml,我在xml文件中提取了服务器的bios设置,并希望使用php仅显示该xml文件的2个字段 这是我拥有的xml文件(名为ndphlsv02.xml) 我有没有办法搜索所有xml文件,只输出名称为“acpwrcvry”和“acpwrcvrydelay”的“属性”及其值 谢谢。简单 $xml = simplexml_load_file('ndphlsv02.xml') or die("Error: Cannot create object"); $xpath = $xml->xpath('/Sy

我在xml文件中提取了服务器的bios设置,并希望使用php仅显示该xml文件的2个字段

这是我拥有的xml文件(名为ndphlsv02.xml)

我有没有办法搜索所有xml文件,只输出名称为“acpwrcvry”和“acpwrcvrydelay”的“属性”及其值

谢谢。

简单

$xml = simplexml_load_file('ndphlsv02.xml') or die("Error: Cannot create object");
$xpath = $xml->xpath('/SystemConfiguration/Component/Attribute[@Name="AcPwrRcvry" or @Name="AcPwrRcvryDelay"]');
foreach ($xpath as $attribute) {
    echo $attribute->attributes()->Name . ': ' . $attribute . '<BR>';
}
有关更多信息,请参见

$xml = simplexml_load_file('ndphlsv02.xml') or die("Error: Cannot create object");
$xpath = $xml->xpath('/SystemConfiguration/Component/Attribute[@Name="AcPwrRcvry" or @Name="AcPwrRcvryDelay"]');
foreach ($xpath as $attribute) {
    echo $attribute->attributes()->Name . ': ' . $attribute . '<BR>';
}
有关更多信息,请参阅

Component[5]->Attribute[3]
$xml = simplexml_load_file('ndphlsv02.xml') or die("Error: Cannot create object");
$xpath = $xml->xpath('/SystemConfiguration/Component/Attribute[@Name="AcPwrRcvry" or @Name="AcPwrRcvryDelay"]');
foreach ($xpath as $attribute) {
    echo $attribute->attributes()->Name . ': ' . $attribute . '<BR>';
}
AcPwrRcvry: Last
AcPwrRcvryDelay: Immediate