Ver Mensaje Individual
  #11 (permalink)  
Antiguo 15/08/2007, 11:54
Avatar de sumolari
sumolari
 
Fecha de Ingreso: mayo-2006
Ubicación: localhost
Mensajes: 1.367
Antigüedad: 17 años, 11 meses
Puntos: 18
Re: leer un archivo y buscar contenido entre etiquetas HTML

Según parece hay que usar archivos XML como fuente de datos. La fuente del censo está en ASP.

Bueno, he usado este código:

Código PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin t&iacute;tulo</title>
</head>

<body>
<?php
$indent 
"";
$file "index.php";

$showfile file_get_contents("http://www.forosdelweb.com" "/" $file);  // whatever path
   // maybe the whole path is not important, look it up in other posts

$newstring=utf8_encode($showfile);          // it's important!
if(!$domDocument domxml_open_mem($newstring)) {
   echo 
"Couldn't load xml...";   
   exit;
}

$rootDomNode $domDocument->document_element();
print 
"<pre>";
printElements($rootDomNode);
print 
"</pre>";

function 
printElements($domNode)
{
  if(
$domNode)
  {
    global 
$indent;
   
    if(
$domNode->node_type() == XML_ELEMENT_NODE)
    {
      print 
"<br />".$indent."&lt;".$domNode->node_name();
      if(
$domNode->has_attributes())
      {
        
$attributes $domNode->attributes();
        foreach(
$attributes as $domAttribute)
        {
          print 
" $domAttribute->name=\"$domAttribute->value\"";
        }
      }
      print 
"&gt;";
      if(
$domNode->has_child_nodes())
      {
        
$indent.="  ";
        
$nextNode $domNode->first_child();
        
printElements($nextNode);
        
$indentsubstr($indent0strlen($indent)-2);
        print 
"<br />".$indent."&lt;"."/".$domNode->node_name()."&gt;";
      }
      else
      {
        print 
"$domNode->node_value()&lt;/".$domNode->node_name()."&gt;";
      }                       
    }
   
    
$nextNode $domNode->next_sibling();
    
printElements($nextNode);
  }
}
?>
</body>
</html>
Edito: Usar foros delweb de fuente no es buena idea, tiene mucho codigo, así que voy a usar mi web