PDA

View Full Version : xml data feed to html??


chuckies126
11-13-2002, 05:39 PM
I'm totally new to XML. I have a vendor that sent me a link to a page that has this as the source. The page has an xsl extension. All I want to do is put the values below into my existing html to display our delayed stock quit. I've been searching the web for 3 days and can't find anything that seems to work.

Can anyone help?

<RECORDS>
<RECORD SRC="ILXPT" INST="ABC">
<FLD F="PRIMARY_MKT_NAME" V="NYSE"></FLD>
<FLD F="PER_CHANGE" V="0.15"></FLD>
<FLD F="LAST_TR_HOUR" V="11"></FLD>
<FLD F="LAST_TR_MINUTE" V="21"></FLD>
<FLD F="HIGH" V="32.92"></FLD>
<FLD F="ANNLOW" V="25.1"></FLD>
<FLD F="CLOSE" V="32.75"></FLD>
<FLD F="LOW" V="32.4"></FLD>
<FLD F="CHANGE" V="0.05"></FLD>
<FLD F="OPEN" V="32.75"></FLD>
<FLD F="SYMBOL" V="MYL"></FLD>
<FLD F="ANNHIGH" V="38.12"></FLD>
<FLD F="VOLUME" V="146600"></FLD>
<FLD F="LAST" V="32.8"></FLD>
<PressWebServiceDiagnostics V="Press Machine: HORN, Press Sources: ILXPT:BLANCO(10.10.104.155);REX(10.10.104.155)"></PressWebServiceDiagnostics>
<IsError V="False"></IsError>
</RECORD>
<IsError V="False"></IsError>
</RECORDS>

dhtroy
11-13-2002, 06:16 PM
Not sure where this will get you, but you can have an <XML> tag in your HTML that references the server page directly


Example
<XML id="myXMLdata" src="http://www.vendorweb.com/stocks.xml"></xml>

I'm guessing that you'll probably want to load the XML and then parse out the data you want. To do this, you'll either have to use Java to load that page off the server and parse the data out, then insert what you want back into the document through the DOM

-or-

use XML Data Islands and XSL Transformations

You can read more about XML Data Islands on Microsoft's MSDN On-line, and they provide some great examples.

ASAAKI
11-13-2002, 06:38 PM
from what I know, XML data islands are IE propriety only.

chuckies126
11-13-2002, 06:41 PM
That what I see also. I must maintain compatibility with Netscape also. Any ideas?

ASAAKI
11-13-2002, 06:54 PM
i'm a few days old at XML myself :o
but i think u cud do it using server-side script, like asp or php, if u're using it ...

dhtroy
11-13-2002, 08:46 PM
Here's a script that will load an XML file for either IE or NS

<script>
var xmlDoc;
function init () {
if (document.all && document.getElementById) {
xmlDoc = new ActiveXObject("Microsoft.XMLDOM")
xmlDoc.async = false;
xmlDoc.load("http://www.vendorweb.com//test123.xml");
showXML();
}
else if (document.implementation &&
document.implementation.createDocument) {
xmlDoc = document.implementation.createDocument('', '', null);
xmlDoc.addEventListener('load', showXML, false);
xmlDoc.load("http://www.vendorweb.com//test123.xml");
}
}
function showXML () {
var nodes = xmlDoc.documentElement.childNodes;
document.getElementById('to').appendChild(
document.createTextNode(nodes.item(0).firstChild.nodeValue)
);
document.getElementById('from').appendChild(
document.createTextNode(nodes.item(1).firstChild.nodeValue)
);
document.getElementById('header').appendChild(
document.createTextNode(nodes.item(2).firstChild.nodeValue)
);
document.getElementById('body').appendChild(
document.createTextNode(nodes.item(3).firstChild.nodeValue)
);
}
</script>

It's not my code - but I'm sure you can figure it out, didn't look too difficult.