0

DOMDocument PHP を使用して WSDL (XML) ドキュメントのノードを見つけることができません。getElementsByTagName を使用すると、常に NULL が返されます。私が見つけようとしているのは xsd:complexType ですが、別のノード、たとえばタイプを試すと、オブジェクトが返されます。

これは私の WSDL (XML) ドキュメントです

<definitions xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="urn:routeDx2" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="urn:routeDx2">
<types>
<xsd:schema targetNamespace="urn:routeDx2"
>
 <xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
 <xsd:import namespace="http://schemas.xmlsoap.org/wsdl/" />
 <xsd:complexType name="inputCashin">
  <xsd:all>
   <xsd:element name="userName" type="xsd:string"/>
   <xsd:element name="signature" type="xsd:string"/>
   <xsd:element name="productCode" type="xsd:string"/>
   <xsd:element name="merchantCode" type="xsd:string"/>
   <xsd:element name="terminal" type="xsd:string"/>
   <xsd:element name="merchantNumber" type="xsd:string"/>
   <xsd:element name="transactionType" type="xsd:string"/>
   <xsd:element name="recipientNumber" type="xsd:string"/>
   <xsd:element name="recipientName" type="xsd:string"/>
   <xsd:element name="amount" type="xsd:string"/>
   <xsd:element name="feeAmount" type="xsd:string"/>
   <xsd:element name="traxId" type="xsd:string"/>
   <xsd:element name="timeStamp" type="xsd:string"/>
  </xsd:all>
 </xsd:complexType>
 <xsd:complexType name="inputCashout">
  <xsd:all>
   <xsd:element name="userName" type="xsd:string"/>
   <xsd:element name="signature" type="xsd:string"/>
   <xsd:element name="productCode" type="xsd:string"/>
   <xsd:element name="merchantCode" type="xsd:string"/>
   <xsd:element name="terminal" type="xsd:string"/>
   <xsd:element name="merchantNumber" type="xsd:string"/>
   <xsd:element name="transactionType" type="xsd:string"/>
   <xsd:element name="recipientNumber" type="xsd:string"/>
   <xsd:element name="recipientName" type="xsd:string"/>
   <xsd:element name="amount" type="xsd:string"/>
   <xsd:element name="feeAmount" type="xsd:string"/>
   <xsd:element name="verifyingCode" type="xsd:string"/>
   <xsd:element name="traxId" type="xsd:string"/>
   <xsd:element name="timeStamp" type="xsd:string"/>
  </xsd:all>
 </xsd:complexType>
</xsd:schema>
</types>
<definitions>

私が見つけようとしているのは xsd:complexType またはそれが可能な場合、一意の値を持つ属性名 (verifyingCode またはその他) で検索する方法、PHP および DOMDocument を介してこれを達成するにはどうすればよいですか?

4

1 に答える 1

0

(最後の行) の終了タグが間違っている以外に<definitions>、問題はありません。

$doc = new DOMDocument();
$doc->loadXML($xml);
$complexTypes = $doc->getElementsByTagName('complexType');
printf('<p>Found %d complexType elements</p>', $complexTypes->length);
foreach ($complexTypes as $complexType) {
    echo $complexType->getAttribute('name'), '<br>';
}

デモ - http://codepad.viper-7.com/95XDsS

xsdタグ名クエリに名前空間を含めている可能性があります。docsを読むと、getElementsByTagName()指定する引数が表示されます

照合するタグのローカル名 (名前空間なし)

于 2012-11-28T05:06:29.507 に答える