DOMXPath ->item(0)-> Проблемы с получением значений типа <Country Code="GR">

iocshas

Новичок
DOMXPath ->item(0)-> Проблемы с получением значений типа <Country Code="GR">

Извените за наивность проблема с поллучением - <Country Code="GR">
- <![CDATA[ Greece
]]>
</Country>

GR из xml


XML:
<?xml version="1.0" encoding="UTF-8" ?>
- <Response ResponseReference="200003">
- <ResponseDetails Language="en">
- <SearchCountryResponse>
- <CountryDetails>
- <Country Code="GR">
- <![CDATA[ Greece
]]>
</Country>
+ <Country Code="GZ">
- <![CDATA[ Greenland
]]>
</Country>
</CountryDetails>
</SearchCountryResponse>
</ResponseDetails>
</Response>


Код <?php

$xml=DOMDocument::load("test.xml");// &#231;&#224;&#227;&#235;&#243;&#248;&#234;&#224;
$responseDoc = $xml;

// Process Response XML Data
if( $responseDoc != NULL ) {
$responseElement = $responseDoc->documentElement;
$xpath = new DOMXPath( $responseDoc );

$searchHotelPriceReponseElements2 = $xpath->query( 'ResponseDetails/SearchCountryResponse/CountryDetails/Country', $responseElement);

$checkInDate=$searchHotelPriceReponseElements2->item(0)->textContent;

echo "ccc=$checkInDate3+$checkInDate2 +".$checkInDate;
}
else {
echo '<p>Invalid Search Request: '.$XMLTransactionHander->errno.'</p>';
}


?>

Содержание узла без проьлем , а как получить значение Code="GR"
 

an_kalinovski

Новичок
ResponseDetails/SearchCountryResponse/CountryDetails/Country[@Code='GR']

а если нужен не узел с таким значением атибута а само значение атрибута то

ResponseDetails/SearchCountryResponse/CountryDetails/Country/@Code
 

iocshas

Новичок
Спссибо огромное....

-~{}~ 15.08.06 13:55:

Автор оригинала: an_kalinovski
ResponseDetails/SearchCountryResponse/CountryDetails/Country[@Code='GR']

а если нужен не узел с таким значением атибута а само значение атрибута то

ResponseDetails/SearchCountryResponse/CountryDetails/Country/@Code
ResponseDetails/SearchCountryResponse/CountryDetails/Country/@Code
То что нужно....
Как раз нужен был атрибут....
 
Сверху