Foros del Web » Programando para Internet » PHP »

Extrair un datos desde un archivo XML

Estas en el tema de Extrair un datos desde un archivo XML en el foro de PHP en Foros del Web. Hola, Tengo un archivo en una pagina y quiero extrair una url de imagen. Aquí esta el XML. Código PHP: < xml >   < Gallery ...
  #1 (permalink)  
Antiguo 11/11/2011, 14:37
Avatar de Amazighweb  
Fecha de Ingreso: junio-2009
Mensajes: 49
Antigüedad: 14 años, 9 meses
Puntos: 0
Extrair un datos desde un archivo XML

Hola,

Tengo un archivo en una pagina y quiero extrair una url de imagen.

Aquí esta el XML.

Código PHP:
<xml>
  <
Gallery>
    <
image>http://www.domaine.com/IMG/image31233.jpg?hash=X&id=1239129329312300d</image>
  
</Gallery>
</
xml
Quiero extrair la URL de la imagen.

¿Como lo puedo hacer?

Saludos.
  #2 (permalink)  
Antiguo 11/11/2011, 14:45
Avatar de jotaincubus  
Fecha de Ingreso: mayo-2005
Ubicación: Medellin - Colombia
Mensajes: 1.797
Antigüedad: 18 años, 11 meses
Puntos: 394
Respuesta: Extrair un datos desde un archivo XML

Amigo mas claro no puede ser LEE

$src = new DOMDocument('1.0', 'utf-8');
$src->formatOutput = true;
$src->preserveWhiteSpace = false;

//Loading extern file
$src->load('../xml/Item_component.xml');

//Check each child of first indexed branch node of: <component>
//First get element after root element: <component>

//1st level
$component = $src->getElementsByTagName('component')->item(0);

//2nd level, get next element after component, here it fails!!
$properties = $component->getElementsByTagName('properties')->item(0);
...
?>
__________________
Por que existe gente que no agradece después de que se le ha brindado tiempo y ayuda ???
  #3 (permalink)  
Antiguo 11/11/2011, 15:16
Avatar de Amazighweb  
Fecha de Ingreso: junio-2009
Mensajes: 49
Antigüedad: 14 años, 9 meses
Puntos: 0
Respuesta: Extrair un datos desde un archivo XML

Hola,

Pero no me funciono,

Saludos.
  #4 (permalink)  
Antiguo 11/11/2011, 15:18
Avatar de jotaincubus  
Fecha de Ingreso: mayo-2005
Ubicación: Medellin - Colombia
Mensajes: 1.797
Antigüedad: 18 años, 11 meses
Puntos: 394
Respuesta: Extrair un datos desde un archivo XML

No le funciono ? muéstrenos el código para poder ayudarle...
__________________
Por que existe gente que no agradece después de que se le ha brindado tiempo y ayuda ???
  #5 (permalink)  
Antiguo 11/11/2011, 16:19
 
Fecha de Ingreso: abril-2009
Ubicación: Colombia
Mensajes: 949
Antigüedad: 15 años
Puntos: 27
Respuesta: Extrair un datos desde un archivo XML

O asi:

Código PHP:
Ver original
  1. <?php
  2. $archivo="tuarchivo.xml";
  3.  $x = new SimpleXMLElement($archivo, null, true);
  4. foreach( $x->Gallery as $url )
  5. {
  6. $url=$url->image;
  7. echo $url;
  8.  
  9. }
  10.  
  11. ?>

Etiquetas: 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 20:25.