Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - Re: Fetch & Read XML Data into HTML File? >Thread Next - Re: Fetch & Read XML Data into HTML File? Re: Fetch & Read XML Data into HTML File?To: NULL Date: 9/9/2008 5:36:00 PM
Richard In Va. wrote:
> <html>
> <title></title>
> <head></head>
No, that is not proper HTML, the title element belongs inside of the
head element and it is good practice to put script elements there too so use
<html>
<head>
<title>...</title>
<script type="text/javascript">
function loadXml (url)
{
// all code of that function goes here
var doc = new ActiveXObject('Msxml2.DOMDocument.3.0');
doc.async = false;
if (doc.load(url))
{
doc.setProperty('SelectionLanguage', 'XPath');
var locEl = doc.selectSingleNode('/weather/loc');
var dnamEl = loc.selectSingleNode('dnam');
var dnam = dnamEl.text;
document.getElementById('dnam').innerText = dnam;
var tmEl = loc.selectSingleNode('tm');
var tm = tmEl.text;
document.getElementById('tm').innerText = tm;
}
}
window.onload = function ()
{
loadXml('http://xoap.weather.com/weather/local/23218?cc=&dayf=7');
};
</script>
</head>
<body>
<table>
<tr>
<td><span id="dnam"></span></td> <!-- location of observation -->
<td><span id="tm"></span></td> <!-- time of observation -->
</tr>
</table>
</body>
</html>
> <!-- Display Day 0 -->
> <table>
> <tr>
> <td><span id="dayName"></span></td> <!-- day of week -->
> <td><span id="t"></span></td> <!-- condition e.g. mostly sunny -->
> <td><span id="hi"></span></td> <!-- day #0 forecast high temp -->
> </tr>
> </table>
As I said, the id must be unique so use e.g.
<span id="dayName0"></span>
<span id="t0"></span>
and so on.
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
