Foros del Web » Programando para Internet » PHP »

Leer Xml segun Contenido

Estas en el tema de Leer Xml segun Contenido en el foro de PHP en Foros del Web. admiro mucho a este foro ya que en dudas pasadas mean ayudado mucho.. hoy estoy aqui con este gran problema, pequeño para ustedes. Estoy tratando ...
  #1 (permalink)  
Antiguo 27/02/2014, 14:32
Avatar de TheBeasth  
Fecha de Ingreso: febrero-2014
Mensajes: 1
Antigüedad: 10 años, 1 mes
Puntos: 0
Leer Xml segun Contenido

admiro mucho a este foro ya que en dudas pasadas mean ayudado mucho.. hoy estoy aqui con este gran problema, pequeño para ustedes.
Estoy tratando de leer el siguiente xml:
Código XML:
Ver original
  1. <ICECAT-interface xsi:noNamespaceSchemaLocation="http://data.icecat.biz/xsd/files.index.xsd">
  2. <files.index Generated="20140227024429">
  3. <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">
  4. <EAN_UPCS>
  5. <EAN_UPC Value="3141725000368"/>
  6. </EAN_UPCS>
  7. </file>
  8. <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">
  9. <M_Prod_ID>A3L791B03MBLU</M_Prod_ID><EAN_UPCS>
  10. <EAN_UPC Value="0722868204931"/><EAN_UPC Value="5053485874739"/></EAN_UPCS>
  11. <Country_Markets>
  12. <Country_Market Value="BE"/>
  13. <Country_Market Value="FR"/>
  14. <Country_Market Value="CZ"/>
  15. <Country_Market Value="NL"/>
  16. <Country_Market Value="SE"/>
  17. <Country_Market Value="GB"/>
  18. <Country_Market Value="HU"/>
  19. <Country_Market Value="NO"/>
  20. <Country_Market Value="AT"/>
  21. <Country_Market Value="ES"/>
  22. <Country_Market Value="IT"/>
  23. <Country_Market Value="DE"/>
  24. <Country_Market Value="DK"/>
  25. <Country_Market Value="CH"/>
  26. </Country_Markets>
  27. </file>
  28. <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">
  29. <EAN_UPCS>
  30. <EAN_UPC Value="0722868204818"/>
  31. <EAN_UPC Value="5055818414056"/>
  32. </EAN_UPCS>
  33. <Country_Markets>
  34. <Country_Market Value="NL"/>
  35. <Country_Market Value="BE"/>
  36. <Country_Market Value="FR"/>
  37. <Country_Market Value="GB"/>
  38. <Country_Market Value="DE"/>
  39. <Country_Market Value="DK"/>
  40. <Country_Market Value="NO"/>
  41. <Country_Market Value="SE"/>
  42. <Country_Market Value="CH"/>
  43. <Country_Market Value="IT"/>
  44. <Country_Market Value="ES"/>
  45. <Country_Market Value="CZ"/>
  46. <Country_Market Value="AT"/>
  47. </Country_Markets>
  48. </file>
  49. </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
  1. $xml = @simplexml_load_file('data.icecat.biz/export/freexml/ES/');
  2. $ns = $xml->getNamespaces(false);
  3. $xml->registerXPathNamespace('c', $ns['files']);
  4. $urls=$xml->xpath('//files.index//file');  
  5.                 foreach ($xml->xpath('//files.index//file') as $file){
  6.                 foreach ($xml->xpath('//files.index//file//Country_Markets//Country_Market') as $con)
  7.                 {  
  8.                 $url='http://efren zamora:[email protected]/'.$file['path'].'';
  9.                   //echo $file['Value'],'<br>';
  10.                  if($con['Value']=="US" || $con['Value']=="ES" )
  11.                 {
  12.                  echo $con['Value'] ,'<br><br>';
  13.                  echo $url1=''.$url.'' ,'<br><br>';                      
  14.                 }}}

Etiquetas: contenido, xml
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 21:28.