我正在尝试从eBaysvc.wsdl中提取一些信息:传递 API_Name 我想检索此类 API 所需的节点名称以及更多信息让我们假设我们想要获取AddDispute
节点,AddDisputeNod
e 作为第一个节点...
<xs:element name="DisputeExplanation" type="ns:DisputeExplanationCodeType" minOccurs="0">
<xs:annotation>
<xs:documentation>
This enumerated ....
</xs:documentation>
<xs:appinfo>
<CallInfo>
<CallName>AddDispute</CallName>
<RequiredInput>Yes</RequiredInput>
<allValuesExcept>PaymentMethodNotSupported, ShipCountryNotSupported, Unspecified, UPIAssistance, UPIAssistanceDisabled</allValuesExcept>
</CallInfo>
<SeeLink>
<Title>Creating and Managing Disputes With Trading API</Title>
<URL>http://developer.ebay.com/DevZone/guides/features-guide/default.html#development/UPI-DisputesAPIManagement.html#UsingAddDispute</URL>
</SeeLink>
</xs:appinfo>
</xs:annotation>
</xs:element>
因此,我构建了以下脚本:
$file = 'ebaysvc.wsdl';
$xmlDoc = new DOMDocument('1.0','UTF-8');
$xmlDoc->preserveWhiteSpace = false;
$xmlDoc->formatOutput = true;
$xmlDoc->load($file);
$xpath = new DomXpath($xmlDoc);
$xpath->registerNamespace('xs', 'http://www.w3.org/2001/XMLSchema');
$API='AddDispute';
$Nodes = $xpath->query('//xs:complexType[@name="'.$API.'RequestType"]/xs:complexContent/xs:extension/xs:sequence')->item(0);
foreach($Nodes->childNodes as $node)
{
$Node_name=$node->getAttribute('name');
$Node_type=str_replace(['ns:','xs:'],'',$node->getAttribute('type'));
echo "<br />".$Node_name.' => '.$Node_type;
}
但我还需要节点的值,我希望它在 foreach 循环中添加这条指令:
$RequiredInput = $xpath->query('xs:annotation/xs:appinfo/CallInfo/RequiredInput',$node)->item(0));
虽然我没有得到任何结果:
我得到它的唯一方法是添加2个嵌套循环:
$RequiredInput = $xpath->query('xs:annotation/xs:appinfo',$node);//->item(0);
foreach($RequiredInput->childNodes as $nn)
{
foreach($nn->childNodes as $nnn)
{
echo '<br />'.$nnn->nodeName.' => '.$nnn->nodeValue;
}
}
似乎不接受内部节点没有 xs: namespace..
但这似乎是我的胡说八道,但我找不到正确的解决方案。可以建议我做错了什么吗?