Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Display XML Element in ASP

Reply
Thread Tools

Display XML Element in ASP

 
 
John Smith
Guest
Posts: n/a
 
      10-30-2005
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 %>


 
Reply With Quote
 
 
 
 
McKirahan
Guest
Posts: n/a
 
      10-31-2005
"John Smith" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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 %>


 
Reply With Quote
 
 
 
 
John Smith
Guest
Posts: n/a
 
      10-31-2005
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "John Smith" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> 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 %>
>
>



 
Reply With Quote
 
McKirahan
Guest
Posts: n/a
 
      10-31-2005
"John Smith" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to Update/insert an xml element's text----> (<element>text</element>) HANM XML 2 01-29-2008 03:31 PM
my hide/display function fails when element begins display:none libsfan01 Javascript 5 01-16-2007 10:40 AM
In xml schema, what's the difference between attribute "final" and "block" in element "element" tankbattle XML 1 07-21-2006 07:51 AM
Problem to insert an XML-element by XSLT-converting from one XML-file into another XML-file jkflens XML 2 05-30-2006 09:41 AM
mixing raw xml display w/ formated display blank101 XML 2 02-05-2005 03:10 PM



Advertisments