Created
August 23, 2011 19:12
Ler arquivo XML com php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* load XML file | |
* LIMIT 4 lines | |
*/ | |
$eventos = simplexml_load_file("agenda.xml"); | |
$count = 0; | |
?> | |
<h1> Noticias </h1> | |
<table id="eventos"> | |
<th> | |
<tr> | |
<td>Dia</td> | |
<td>Local</td> | |
<td>Horário</td> | |
<td></td> | |
</tr> | |
</th> | |
<?php foreach($eventos->evento as $evento): if($count < 4):?> | |
<tr> | |
<td> <?= $evento->dia ?> </td> | |
<td> <?= $evento->local ?> </td> | |
<td><?= $evento->horario ?></td> | |
<td> <a href="<?= $evento->link?>"> Link </a> </td> | |
</tr> | |
<?php $count++; endif; endforeach;?> | |
<table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="iso-8859-1"?> | |
<!-- | |
Documentação: | |
Para cada evento deve existir um bloco identico ao bloco abaixo dentro da estrutura "<eventos>": | |
<evento> | |
<dia> Data do evento </dia> | |
<local> Local do evento </local> | |
<horario> Horário do evento </horario> | |
<link> Link para o evento </link> | |
</evento> | |
--> | |
<eventos> | |
<evento> | |
<dia> Evento 1 </dia> | |
<local> Rua X </local> | |
<horario> 10:30 </horario> | |
<link> http://www.lqdi.net </link> | |
</evento> | |
<evento> | |
<dia> 212133 </dia> | |
<local> 2112121 </local> | |
<horario> 212121 </horario> | |
<link> http://www.lqdi.net </link> | |
</evento> | |
<evento> | |
<dia> </dia> | |
<local> </local> | |
<horario> </horario> | |
<link> http://www.lqdi.net </link> | |
</evento> | |
<evento> | |
<dia> </dia> | |
<local> </local> | |
<horario> </horario> | |
<link> http://www.lqdi.net </link> | |
</evento> | |
</eventos> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment