Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang = "es">
  3. <head>
  4. <meta charset="utf-8" />
  5. <title>Carga de XML con AJAX y PHP</title>
  6. <meta name="description" content="Ejercicio para mostrar dinámicamente la lista de ciudades de cada país del mundo con XML, AJAX y PHP." />
  7. <script src="cargar_ciudades.js"></script>
  8. </head>
  9. <body>
  10. <form method="post">
  11. <label for="listaPaises">Pais: </label>
  12. <select id="listaPaises" name="pais_slc" onchange=" return mostrarCiudades()">
  13. <option value="">- - -</option>
  14. <?php
  15. $xml = simplexml_load_file("paises.xml");
  16. $resultado = $xml->xpath("/lista/paises/nombre | /lista/paises/@id");
  17. for($i=0;$i<count($resultado);$i+=2)
  18. {
  19. $elegido = $i+1;
  20. $pais = utf8_decode($resultado[$elegido]);
  21. echo "<option value='$pais'>$pais</option>";
  22. }
  23. ?>
  24. </select>
  25. <label for="listaCiudades">Ciudades: </label>
  26. <select id="listaCiudades" name="ciudad_slc">
  27. <option value="">- - -</option>
  28. </select>
  29. <span id="espera"></span>
  30. </form>
  31. </body>
  32. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement