Almost there, but it won't read the XML data if I try HTTP:
oXML.load("http://dgcsc.org/goldprices.xml")
'* Doesn't work. I hardcoded the URL just to make sure it was calling the
correct location.
oXML.load(Server.MapPath("goldprices.xml"))
'* Works perfectly. For testing purposes I copied the goldprices.xml file
from dgcsc.org into the same directly on the server as the ASP file.
Anyone got any ideas how to get this last bit to work?
Here's the complete code:
<%@ LANGUAGE="VBSCRIPT" %>
<% Option Explicit
'*
Const cOZT = 31.103477
Const cURL = "http://dgcsc.org/goldprices.xml"
'*
Dim iPRC
iPRC = 0.0000
'*
Dim oXML
Set oXML = CreateObject("Microsoft.XMLDOM")
oXML.async = "false"
'* oXML.load(cURL)
oXML.load(Server.MapPath("goldprices.xml"))
iPRC = oXML.getElementsByTagName("Price").item(21).text
Set oXML = Nothing
'*
Response.Write "Gold Price: $" & Round(iPRC * cOZT,4) & " per ounce"
%>
"McKirahan" <> wrote in message
news:i7-dnTJ9-_ERKyXfRVn-...
> <> wrote in message
> news:...
> > I can't quite figure out this last part. How do I pull the value for:
> > <Price currencyname="United States Dollar"
> > currencycode="USD">14.0788</Price>
> > from http://dgcsc.org/goldprices.xml and use it in my ASP code for the
> > variable GoldPrice_Gram? Thanks.
> >
> > <%@ LANGUAGE="VBSCRIPT" %>
> > <%
> > GoldPrice_Gram = 14.0788
> > GramsPerTroyOunce = 31.103477
> > GoldPrice_Ounce = GoldPrice_Gram * GramsPerTroyOunce
> >
> > response.write "Gold Price: " & round(GoldPrice_Ounce,4)
> > %>
> >
> >
> >
> > "Tim Slattery" <> wrote in message
> > news:...
> > > wrote:
> > >
> > > >
> > > >
> > > > wrote:
> > > >> Does anyone know an easy way to put a current gold price on your
own
> > > >> website? I've seen the graphic methods that Kitco.com offers, but
> I'd
> > > >> rather have it pull the value from some gold market system in text
> > format.
> > > >>
> > > >> I found a website that's doing it, but don't know where to start in
> > reverse
> > > >> engineering the code:
> > > >> http://www.goldinvestment.com/Purchasing/Scrap_Gold.asp
> > > >>
> > > >> Thanks
> > > >
> > > >Oh, prices are in grams.
> > > >
> > > >1 ounce = 28.3495231 grams
> > >
> > > I believe that's one avoirdupois ounce. But precious metals are sold
> > > in Troy ounces.....
> > >
> > > According to http://en.wikipedia.org/wiki/Troy_weight, one Troy ounce
> > > is 31.103477 gram.
> > >
> > > --
> > > Tim Slattery
> > > MS MVP(DTS)
> > >
> >
> >
>
> Will this help? Watch for word-wrap.
>
> <%@ LANGUAGE="VBSCRIPT" %>
> <% Option Explicit
> '*
> Const cOZT = 31.103477
> Const cURL = "http://dgcsc.org/goldprices.xml"
> '*
> Dim iPRC
> iPRC = 0.0000
> '*
> Dim oXML
> Set oXML = CreateObject("Microsoft.XMLDOM")
> oXML.async = "false"
> oXML.load(cURL)
> iPRC = oXML.getElementsByTagName("Price").item(21).text
> Set oXML = Nothing
> '*
> Response.Write "Gold Price: $" & Round(iPRC * cOZT,4) & " per ounce"
> %>
>
> This assumes that "USD" is always at the same offset in the XML file.
>
>