Ir para conteúdo
Fórum Script Brasil

lucasfbfb

Membros
  • Total de itens

    1
  • Registro em

  • Última visita

Posts postados por lucasfbfb

  1. Galera tou fazendo meu php ler um tipo de um Xml, nele possui 2 tags filhas iguais.

    eu quero capturar e mostrar os termos das tags category

    ...

    <entry>

    ...

    <category term="TIPO"></category>

    <category term="CATEGORIA"></category>

    ...

    </entry>

    ...

    CODIGO UTILIZADO:

    $post = new XMLReader();
    $post->open('blog.xml');
    while ($post->read()) {
    switch ($post->nodeType) {
    case (XMLReader::ELEMENT):
    if ($post->localName == "entry") {
    $node = $post->expand();
    $dom = new DomDocument();
    $n = $dom->importNode($node,true);
    $dom->appendChild($n);
    $simple_xml = simplexml_import_dom ($n);
    $date = $simple_xml->published;
    $type = $simple_xml->category['term'];
    $title = $simple_xml->title;
    $cont = $simple_xml->content;
    $author = $simple_xml->author->name;
    if ($type == $t) {
    echo $title." - ".$type." - ".$author." - ".$date;
    echo "<br/><br/><br/><br/>";
    }
    }
    }
    }

×
×
  • Criar Novo...