E:\web\learnaspcom\htdocs\freebook\learn\ubtoc.xml LearnAsp.com - ASP ASP.net Free Lessons
Search Search

#1 worldwide
FREE Coding Lessons

since 1996
   THE BEST WAY to learn ASP & Asp.net!
Advertise Here!
click for details
Credits Host:
DiscountASP.net
Server Admin:
The "Team"
Contact Info.
Charles M. Carroll
<Asp.net blog>
<personal site>
xxx

Yahoo Store Viewer from Web
by Charles Carroll with Ronda Kay Pederson

The code below can read any Yahoo store if XML export is turned on. An alternative version of this program that works against a Yahoo file stored locally is at /learn/yahoostore.aspx.

Other locations you may want to try are http://store.yahoo.com/yhst-1443191082283/objinfo.xml and http://store.yahoo.com/lingeriesite/objinfo.xml. This little simple utility makes it easy for a human to look at the complex XML files that Yahoo exports as rows and columns.

More information: our ongoing Yahoo store programming with ASP.net continues, you can find out more by joining our ASP.net Yahoo stores list.

   filename=/experiments/yahoostores/yahoostoreviewerweb.aspx

<Test Script Below>


<%@ debug="true"%>
<%@ Import Namespace="System.Net" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Data" %>

<script language="VB" runat="server">
SUB Page_Load(Src As Object, E As EventArgs) 
    If ispostback=false THEN
        storeURL.text="http://store.yahoo.com/yhst-1443191082283/objinfo.xml"
    ELSE
        Dim ds As New DataSet
        dim tablecount as integer
        dim tablecurrent as integer
        DIM datafromURL as streamreader
    
        datafromURL=readURLstream(storeURL.text)
        ds.ReadXml(datafromURL)
        dim counter as integer
        tablecount=ds.tables.count()
        'response.write ("tablecount=" & tablecount & "<br>")
        TRY
            tablecurrent=cint(whichdataview.selecteditem.text())
        CATCH
            tablecurrent=0
        END TRY
        whichdataview.items.clear()
        FOR counter=0 TO tablecount-1
            whichdataview.items.add (counter)
        NEXT
        whichdataview.SelectedIndex = whichdataview.Items.IndexOf(whichdataview.Items.FindByValue("8"))
        tablecurrent=7
        MyDataGrid.DataSource = new DataView(ds.Tables(tablecurrent))
        MyDataGrid.DataBind()
        datafromURL.close
    END IF
END SUB

Function readURLstream(url As String) As StreamReader
      Dim objResponse As WebResponse
      Dim objRequest As WebRequest
      Dim result As String
      objRequest = System.Net.HttpWebRequest.Create(url)
      objResponse = objRequest.GetResponse()
      Dim sr As New StreamReader(objResponse.GetResponseStream())
      return sr
End Function
</script>

<html>
<body>

<h3>XML File Viewer</h3>
<form runat="server" >
<b>URL to Store:</b>&nbsp;<asp:textbox id="storeURL" columns="60" runat="server" /><br>
<asp:dropdownlist id="whichdataview" autopostback="true" EnableViewState="true" runat="server"/>
&nbsp;<asp:Button text="Load XML File" runat="server" />
<br>
<asp:literal id="testoutput" runat="server"/><br>
<ASP:DataGrid id="MyDataGrid" runat="server"
    BackColor="white" 
    BorderColor="black"
    ShowFooter="false" 
    CellPadding=3 
    CellSpacing="0"
    Font-Name="Verdana"
    Font-Size="8pt"
    Headerstyle-BackColor="lightblue"
    Headerstyle-Font-Size="10pt"
    Headerstyle-Font-Style="bold"
/>
</form>
</body>
</html>
Chaz Wish List
Tall Tip $5
Grande Tip $20
Venti Tip $39
Tip Jar Thanks
2004 Thanks
2005 Thanks
HUGE Tip -love site