Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Fetch & Read XML Data into HTML File?

From: Martin Honnen <mahotrash@-----.-->
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/


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent