您可以使用SimpleElement::children
和SimpleElement::attributes
的名称空间参数来检索此信息:
// Retrieve the `wsdl:` namespaced children of the operation
[$input,$output] = $result[0]->children('wsdl',true);
// Retrieve the `wsaw:`-namespaced attributes of the input element,// then grab the one named Action
$actionAttribute = $input->attributes('wsaw',true)->Action;
// Convert its value into a string
$actionUrl = (string)$actionAttribute;
(显然,此答案对此已过分评论。)
,
有两种方法可以直接使用input
查找感兴趣的xpath
元素。您可以按当前的状态使用local-name()
$xpath = "//*[local-name()='operation'][@name='$method']/*[local-name()='input']";
或直接在xpath
中指定名称空间:
$xpath = "//wsdl:operation[@name='$method']/wsdl:input";
一旦有了所需的元素,就可以查看Action
的命名空间属性:
$result = $xmlWSDL->xpath($xpath)[0];
$namespaces = $result->getNameSpaces();
foreach ($namespaces as $ns) {
if (isset($result->attributes($ns)['Action'])) $url = (string)$result->attributes($ns)['Action'];
}
echo $url;
输出:
http://www.cnj.jus.br/servico-intercomunicacao-2.2.2/consultarProcesso
Demo on 3v4l.org
本文链接:https://www.f2er.com/3010830.html