Display XML Element in ASP

Discussion in 'ASP General' started by John Smith, Oct 30, 2005.

  1. John Smith

    John Smith Guest

    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 %>
     
    John Smith, Oct 30, 2005
    #1
    1. Advertising

  2. John Smith

    McKirahan Guest

    "John Smith" <> wrote in message
    news:...
    > 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 %>
     
    McKirahan, Oct 31, 2005
    #2
    1. Advertising

  3. John Smith

    John Smith Guest

    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" <> wrote in message
    news:...
    > "John Smith" <> wrote in message
    > news:...
    >> 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 %>
    >
    >
     
    John Smith, Oct 31, 2005
    #3
  4. John Smith

    McKirahan Guest

    "John Smith" <> wrote in message
    news:...
    > 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/xmldom/quickref/node_selectSingleNode.ht
    ml
     
    McKirahan, Oct 31, 2005
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. blank101
    Replies:
    2
    Views:
    535
    blank101
    Feb 5, 2005
  2. jkflens
    Replies:
    2
    Views:
    1,497
    jkflens
    May 30, 2006
  3. tankbattle
    Replies:
    1
    Views:
    806
    George Bina
    Jul 21, 2006
  4. HANM
    Replies:
    2
    Views:
    723
    Joseph Kesselman
    Jan 29, 2008
  5. libsfan01
    Replies:
    5
    Views:
    153
    Evertjan.
    Jan 16, 2007
Loading...

Share This Page