Your SlideShare is downloading. ×
Convertir archivo xml a html con php
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Convertir archivo xml a html con php

1,558
views

Published on

Convertir archivo xml a html con php

Convertir archivo xml a html con php

Published in: Education

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,558
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
8
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Convertir archivo XML a HTML con PHPEstructura no_guia.xml
  • 2. Código PHP
  • 3. Resultado:Código:1.- No_guia.xml<?xml version="1.0" encoding="utf-8"?><pma_xml_export version="1.0"xmlns:pma="http://www.phpmyadmin.net/some_doc_url/"><database name="e-dbase"><table><idguia>1</idguia><order_number>31e003</order_number><numguia>116666</numguia><exportado>1</exportado></table><table><idguia>2</idguia><order_number>TOSHI000000000005-1</order_number><numguia>116661</numguia><exportado>1</exportado></table><table><idguia>3</idguia><order_number>TOSHI000000000006-1</order_number>
  • 4. <numguia>116662</numguia><exportado>1</exportado></table><table><idguia>4</idguia><order_number>TOSHI000000000007-1</order_number><numguia>11663</numguia><exportado>1</exportado></table><table><idguia>5</idguia><order_number>TOSHI000000000012-1</order_number><numguia>116665</numguia><exportado>1</exportado></table><table><idguia>6</idguia><order_number>TOSHI000000000013-1</order_number><numguia>116669</numguia><exportado>1</exportado></table></database></pma_xml_export>2.- Archivo.php<html><body><head><style type="text/css">body {color: purple;background-color: #d8da3d } h1 {font-family: Helvetica, Geneva, Arial,SunSans-Regular, sans-serif }
  • 5. </style></head><script>if (window.XMLHttpRequest){// Código para soportar los diferentes navegadores IE7+, Firefox, Chrome,Opera, Safarixmlhttp=new XMLHttpRequest(); }else {// Código para los vavegadores IE6, IE5xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");} //cargamos el nombre del archivo XML a procesar en este caso:no_guia.xmlxmlhttp.open("GET","no_guia.xml",false);xmlhttp.send();xmlDoc=xmlhttp.responseXML;//Insdertamremos los datos en una tabladocument.write("<table border=1>");// El tag a procesar es tabla y dentro de cada tag tabla existen otros tagsvar x=xmlDoc.getElementsByTagName("table");for (i=0;i<x.length;i++){document.write("<TITLE>Importar XML a HTML</TITLE>");document.write("<tr><td>"); //Definimos el color y tamaño del textodocument.write("<font color=red size=4>");document.write("<strong>");document.write(x[i].getElementsByTagName("idguia")[0].childNodes[0].nodeValue);document.write("</strong>");document.write("</font>");document.write("</td><td>");
  • 6. document.write("<td>");document.write("<strong>"); //Definimos tipo de fuente para el texto HTMLdocument.write("<font face=Comic Sans MS,arial,verdana>");document.write(x[i].getElementsByTagName("order_number")[0].childNodes[0].nodeValue);document.write("</strong>");document.write("</font>");document.write("</td><td>");document.write("<strong>");document.write(x[i].getElementsByTagName("numguia")[0].childNodes[0].nodeValue);document.write("</strong>");document.write("</td><td>");document.write(x[i].getElementsByTagName("exportado")[0].childNodes[0].nodeValue);document.write("</td></tr>"); } // Cerramos la tabladocument.write("</table>");</script></body></html>