Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HTML does not display data from XML file

Status
Not open for further replies.

SitesMasstec

Programmer
Sep 26, 2010
508
Brasil
Hello colleagues!

When I open the file LISTA.HTM in Internet Explorer or Chrome, there is no data binding with LISTA.XML. It is displaying just the header, without any record. What am I missing?

HTMLXML1a_iuyktm.jpg

LISTA.HTM:
Code:
<html>
<head>
<title>Uso de Data Islands</title>
</head>

<style type="text/css">
  body {font: 80% verdana; background-color: beige}
  td {font-size: 80%}
  th {font-size: 90%}
</style>

<body>

<xml id="dados" src="lista.xml"></xml>

<table datasrc="#dados" border="1" cellpadding="4" cellspacing="0" bordercolor="black">
  <thead>
    <tr>
      <th>Código</th>
      <th>Título</th>
      <th>Cantor</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td align="center"><span datafld="cod"></span></td>
      <td><span datafld="titulo"></span></td>
      <td><span datafld="cantor"></span></td>
    </tr>
  </tbody>
</table>

</body>
</html>

LISTA.XML:
Code:
<?xml version="1.0" encoding="iso-8859-1"?>
<colecao>
  <cds>
    <cod>3949</cod>
    <titulo>Fear of the Dark</titulo>
    <cantor>Iron Maiden</cantor>
  </cds>
  <cds>
    <cod>1113</cod>
    <titulo>The Black Album</titulo>
    <cantor>Metallica</cantor>
  </cds>
  <cds>
    <cod>9449</cod>
    <titulo>As canções que você fêz pra mim</titulo>
    <cantor>Roberto Carlos</cantor>
  </cds>
  <cds>
    <cod>9564</cod>
    <titulo>Old Hits</titulo>
    <cantor>The Beatles</cantor>
  </cds>
  <cds>
    <cod>3444</cod>
    <titulo>Baile dos Namorados</titulo>
    <cantor>Alberto Nobres</cantor>
  </cds>
  <cds>
    <cod>9864</cod>
    <titulo>The Masters of Blues</titulo>
    <cantor>New York National Blues Band</cantor>
  </cds>  
</colecao>

Thank you,
SitesMasstec
 
I'm confused. Why do you think a flat text (html) file would be able to magically pull in an external XML file?

HTML is stateless text that is interpreted in a browser. But has no connection to anything outside of it on its own.

If you need to pull in an XML file you need to use some type of active code like Javascript or PHP etc... to pull it in and output it with the HTML.



----------------------------------
Phil AKA Vacunita
----------------------------------
OS-ception: Running Linux on a Virtual Machine in Windows which itself is running in a Virtual Machine on Mac OSx.

Web & Tech
 

Phil:
The HTML text is able to display an external document. Example:
<IMG SRC="computer.gif" ALIGN="MIDDLE">



Thank you,
SitesMasstec
 
An image is not a xml file.

And even then there is an explicit definition of the image file to be shown. The Browser reads the image tag and understands it needs to load an image.

You have nothing that would even remotely begin to tell the browser to pull in an XML file.

----------------------------------
Phil AKA Vacunita
----------------------------------
OS-ception: Running Linux on a Virtual Machine in Windows which itself is running in a Virtual Machine on Mac OSx.

Web & Tech
 
Hi

Phil said:
You have nothing that would even remotely begin to tell the browser to pull in an XML file.
Personally I would say pulling it in is the smaller issue. Seeing a [tt]<object [maroon]data[/maroon][teal]=[/teal][green]"lista.xml"[/green] [maroon]type[/maroon][teal]=[/teal][green]"text/xml"[/green]></object>[/tt], the browser will happily load it. But who on Earth will process it ?

My theory is that SitesMasstec took that code from a server where some server side processing was configured for this. But according to the screenshot he now opens it directly from filesystem, so no way any processing to happen.


Feherke.
feherke.github.io
 
feherke said:
Personally I would say pulling it in is the smaller issue. Seeing a <object data="lista.xml" type="text/xml"></object>, the browser will happily load it. But who on Earth will process it ?

True, but the code shown doesn't even have that.

Further to get it into a table would require processing and display code.

The object tag would just pull it in as plain text.

The question was more geared towards why they thought simply naming the files the same would have the html page show the xml in a nice table layout without any additional code whatsoever.

----------------------------------
Phil AKA Vacunita
----------------------------------
OS-ception: Running Linux on a Virtual Machine in Windows which itself is running in a Virtual Machine on Mac OSx.

Web & Tech
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top