INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

HTML does not display data from XML file

HTML does not display data from XML file

(OP)
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?


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

RE: HTML does not display data from XML file

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

RE: HTML does not display data from XML file

(OP)

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

Thank you,
SitesMasstec

RE: HTML does not display data from XML file

You are correct that HTML text is able to display an external document as the IMG tag. You are incorrect to assume this applies as easily with the XML document you reference.

Try these articles:

https://www.google.com/search?q=load+xml+into+html...

RE: HTML does not display data from XML file

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

RE: HTML does not display data from XML file

Hi

Quote (Phil)

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 <object data="lista.xml" type="text/xml"></object>, 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

RE: HTML does not display data from XML file

Quote (feherke)

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close