我想直接获取特定属性的值而不使用 foreach 例如
我的代码:
$xmldoc = new DOMDocument;
$xmldoc->loadXML($this->Stream);
$xpa = new DOMXPath($xmldoc);
$titles = $xpa->query("//tpd:ParameterSet[@ProcessUsage='Customer']/tpd:Parameter/tpd:CustomerInfo");
foreach ($titles as $title) {
if ($title->hasAttributes()) {
foreach ($title->attributes as $attribute) {
print "AttributName= " . $attribute->name . "\n";
print "AttributValue= " . $attribute->value . "\n";
}
}
到目前为止,它将为您提供输出:
"T:\Program\PHP\php.exe" T:\run.php
AttributName= CustomerID
AttributValue= 1223
AttributName= CustomerOrderID
AttributValue= 1552045326210
Process finished with exit code 0
我的问题: 是否可以直接获取 tpd:CustomerInfo/CustomerOrderID 的属性值?
谢谢你的帮助!