Display XML Element in ASP

J

John Smith

Hi,

I'm trying to write a piece of ASP that will allow me to display only one
element of a XML file. I am new to XML and wanted to find out what I am
doing wrong. I think it may be to do with the nodes ? When this is currently
run it comes up with the error "Overflow" ('800a0006').

Any pointers or solutions ?

Thanks

J.

This is the XML (page.xml) :

<stocklist>
<stock tidm="VOD">
<exchange>LSE</exchange>
<symbol>VOD</symbol>
<fullname>VODAFONE GRP.</fullname>
<currency>GBX</currency>
<midprice>143.5 (28OCT)</midprice>
<bidprice>143.5</bidprice>
<offerprice>143.75</offerprice>
<valuechange>+2.5</valuechange>
<percentchange>+1.77</percentchange>
<yearhigh>156.5</yearhigh>
<yearlow>132.75</yearlow>
<dayhighmid>0</dayhighmid>
<daylowmid>0</daylowmid>
<volume>0</volume>
<tradecount>0</tradecount>
<previouscloseprice>141</previouscloseprice>
<timestamp>Sun Oct 30 13:46:01 2005</timestamp>
</stock>
</stocklist>

And this is the code that should output the "midprice" :

<%
Option Explicit
Response.Buffer = True

Dim xml
Set xml = Server.CreateObject("Microsoft.XMLDOM")
xml.async = False
xml.load (Server.MapPath("page.xml"))

Dim midprice,stocklist
Set midprice = xml.documentElement.selectNodes(stocklist/midprice).text
%>
<%= midprice %>
 
M

McKirahan

John Smith said:
Hi,

I'm trying to write a piece of ASP that will allow me to display only one
element of a XML file. I am new to XML and wanted to find out what I am
doing wrong. I think it may be to do with the nodes ? When this is currently
run it comes up with the error "Overflow" ('800a0006').

Any pointers or solutions ?

Thanks

J.

This is the XML (page.xml) :

<stocklist>
<stock tidm="VOD">
<exchange>LSE</exchange>
<symbol>VOD</symbol>
<fullname>VODAFONE GRP.</fullname>
<currency>GBX</currency>
<midprice>143.5 (28OCT)</midprice>
<bidprice>143.5</bidprice>
<offerprice>143.75</offerprice>
<valuechange>+2.5</valuechange>
<percentchange>+1.77</percentchange>
<yearhigh>156.5</yearhigh>
<yearlow>132.75</yearlow>
<dayhighmid>0</dayhighmid>
<daylowmid>0</daylowmid>
<volume>0</volume>
<tradecount>0</tradecount>
<previouscloseprice>141</previouscloseprice>
<timestamp>Sun Oct 30 13:46:01 2005</timestamp>
</stock>
</stocklist>

And this is the code that should output the "midprice" :

<%
Option Explicit
Response.Buffer = True

Dim xml
Set xml = Server.CreateObject("Microsoft.XMLDOM")
xml.async = False
xml.load (Server.MapPath("page.xml"))

Dim midprice,stocklist
Set midprice = xml.documentElement.selectNodes(stocklist/midprice).text
%>
<%= midprice %>


http://www.devguru.com/Technologies/xmldom/quickref/node_selectNodes.html


<%
Option Explicit
Response.Buffer = True
Dim midprice

Dim xml
Set xml = Server.CreateObject("Microsoft.XMLDOM")
xml.async = False
xml.load (Server.MapPath("page.xml"))

Dim NodeList
Set NodeList = xml.documentElement.selectNodes("stock/midprice")
Dim Node
For Each Node In NodeList
midprice = Node.text
Next
%>
<%= midprice %>
 
J

John Smith

Thanks for that, I'm still not quite getting this though ! If I wanted to
expand on this and have several of the nodes in the output is it just a
question of adding them to the nodelist ?

Thanks,

J.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top