繁体   English   中英

PHP-如何从nusoap响应中提取响应代码?

[英]PHP - How to extract the reponse code from nusoap response?

这是WSDL的响应

<return code='6000'></return>

我想返回代码值。 我可以使用simplexml_load_string()吗?

是的你可以。

$xml = simplexml_load_string($str);

$code = (int) $xml->attributes()->code;

键盘

您可以使用DOMDocument()获取节点值以及属性值。

$dom_boj=new DOMDocument(); //Creating object to the class DOMDocument()
$dom_boj->loadXML($XMLResponse); // loading your response using loadXML

//Traversing all return tags. 

foreach($dom_boj->getElementByTagName('return') as $tagName)  
{            
                 echo $tagName->getAttribute('code');   
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM