1 を指定しないと__getLastResponseが使えない $client = new SoapClient("http://api.porta.ndl.go.jp/servicedp/services/SRWDp?wsdl", array('trace' => 1)); //リクエストの準備 //クエリはCQL //ここでは 'recordPacking' => 'string', 'recordSchema' => 'dcndl_porta' $q = '(isbn = 4000074628) AND (dpid ANY "zomoku")'; $req = array('version' => '1.1', 'query' => $q, 'startRecord' => '1', 'maximumRecords' => '200', 'recordPacking' => 'string', 'recordSchema' => 'dcndl_porta'); $starttime = getmicrotime(); //リクエスト $client->searchRetrieveOperation($req); //データ取得時間出力 print('データ取得時間 = '.(getmicrotime() - $starttime).'秒'); //XML文字列取得 $xmlstr = $client->__getLastResponse(); //XML文字列を出力 print_r('
'.htmlspecialchars($xmlstr).'
'); //XML文字列をオブジェクトツリーへ変換 $r = simplexml_load_string($xmlstr); //1つ目のアイテムのrecordDataを取得 $srr = $r->children('http://schemas.xmlsoap.org/soap/envelope/')->Body->children('http://www.loc.gov/zing/srw/'); $rd = simplexml_load_string($srr->searchRetrieveResponse->records->record[0]->recordData, 'SimpleXMLElement', LIBXML_NOCDATA); //1つ目のアイテムのrecordDataを出力 //いくつかのネームスペースの要素が混在してるのでそれぞれを出力 print_r('
');
print_r($rd->children('http://purl.org/dc/elements/1.1/'));		//dc
print_r($rd->children('http://purl.org/dc/dcmitype/'));			//dcmitype
print_r($rd->children('http://ndl.go.jp/dcndl/terms/'));		//dcndl
print_r($rd->children('http://ndl.go.jp/dcndl/dcndl_porta/'));	//dcndl_porta
print_r($rd->children('http://purl.org/dc/terms/'));			//dcterms
print_r('
'); //dc:identifierなどの属性xsi:typeを取得したいがやりかたがわからない ?>