469,588 Members | 2,688 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,588 developers. It's quick & easy.

Display XML Element in ASP

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 %>
Oct 30 '05 #1
3 2444
"John Smith" <jo**@smith.com> wrote in message
news:_4********************@pipex.net...
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/...lectNodes.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 %>
Oct 31 '05 #2
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.
"McKirahan" <Ne**@McKirahan.com> wrote in message
news:y4********************@comcast.com...
"John Smith" <jo**@smith.com> wrote in message
news:_4********************@pipex.net...
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/...lectNodes.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 %>

Oct 31 '05 #3
"John Smith" <jo**@smith.com> wrote in message
news:Ld******************************@pipex.net...
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 ?


[snip]

I'm not sure...
Also, if you have more than one <stock> you should use "selectSingleNode".

http://www.devguru.com/Technologies/...tSingleNode.ht
ml

Oct 31 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Jeff Thies | last post: by
1 post views Thread by Jon W | last post: by
19 posts views Thread by dmiller23462 | last post: by
7 posts views Thread by Stefan Finzel | last post: by
15 posts views Thread by Markus Ernst | last post: by
7 posts views Thread by khinester | last post: by
8 posts views Thread by Haines Brown | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.