Estoy tratando de leer el siguiente xml:
Código XML:
Ver original
<ICECAT-interface xsi:noNamespaceSchemaLocation="http://data.icecat.biz/xsd/files.index.xsd"> <files.index Generated="20140227024429"> <file path="export/freexml.int/ES/1431.xml" Product_ID="1431" Updated="20140226153540" Quality="SUPPLIER" Supplier_id="1" Prod_ID="CHP113" Catid="714" On_Market="0" Model_Name="Office Paper-2500 sht/A4/210 x 297 mm" Product_View="135" HighPic="http://images.icecat.biz/img/norm/high/1431-HP.jpg" HighPicSize="24997" HighPicWidth="400" HighPicHeight="400" Date_Added="20051104000000"> <EAN_UPCS> <EAN_UPC Value="3141725000368"/> </EAN_UPCS> </file> <file path="export/freexml.int/ES/27563.xml" Product_ID="27563" Updated="20140226080121" Quality="ICECAT" Supplier_id="32" Prod_ID="A3L791B03M-BLUS" Catid="830" On_Market="1" Model_Name="Cable patch CAT5 RJ45 snagless 3m blue" Product_View="211" HighPic="http://images.icecat.biz/img/norm/high/15743_27563-7948.jpg" HighPicSize="23853" HighPicWidth="250" HighPicHeight="250" Date_Added="20050715000000"> <M_Prod_ID>A3L791B03MBLU</M_Prod_ID><EAN_UPCS> <EAN_UPC Value="0722868204931"/><EAN_UPC Value="5053485874739"/></EAN_UPCS> <Country_Markets> <Country_Market Value="BE"/> <Country_Market Value="FR"/> <Country_Market Value="CZ"/> <Country_Market Value="NL"/> <Country_Market Value="SE"/> <Country_Market Value="GB"/> <Country_Market Value="HU"/> <Country_Market Value="NO"/> <Country_Market Value="AT"/> <Country_Market Value="ES"/> <Country_Market Value="IT"/> <Country_Market Value="DE"/> <Country_Market Value="DK"/> <Country_Market Value="CH"/> </Country_Markets> </file> <file path="export/freexml.int/ES/27571.xml" Product_ID="27571" Updated="20140226080121" Quality="ICECAT" Supplier_id="32" Prod_ID="A3L791B01M-S" Catid="883" On_Market="1" Model_Name="Cable patch CAT5 RJ45 snagless 1m grey" Product_View="152" HighPic="http://images.icecat.biz/img/norm/high/15743_27571-436.jpg" HighPicSize="17169" HighPicWidth="250" HighPicHeight="250" Date_Added="20050715000000"> <EAN_UPCS> <EAN_UPC Value="0722868204818"/> <EAN_UPC Value="5055818414056"/> </EAN_UPCS> <Country_Markets> <Country_Market Value="NL"/> <Country_Market Value="BE"/> <Country_Market Value="FR"/> <Country_Market Value="GB"/> <Country_Market Value="DE"/> <Country_Market Value="DK"/> <Country_Market Value="NO"/> <Country_Market Value="SE"/> <Country_Market Value="CH"/> <Country_Market Value="IT"/> <Country_Market Value="ES"/> <Country_Market Value="CZ"/> <Country_Market Value="AT"/> </Country_Markets> </file> </files.index>
necesto obtener la url que se encuentra en la etiqueta file con el atributo path siempre y cuando la la etiqueta Country_Markets value sea igual a "US" ó "ES" mi codigo que tengo no me funicona me duplica solo una url la primera
Este es mi codigo PHP:
Código PHP:
Ver original
$ns = $xml->getNamespaces(false); $xml->registerXPathNamespace('c', $ns['files']); $urls=$xml->xpath('//files.index//file'); foreach ($xml->xpath('//files.index//file') as $file){ foreach ($xml->xpath('//files.index//file//Country_Markets//Country_Market') as $con) { //echo $file['Value'],'<br>'; if($con['Value']=="US" || $con['Value']=="ES" ) { echo $con['Value'] ,'<br><br>'; echo $url1=''.$url.'' ,'<br><br>'; }}}