CSDN博客

img xuandhu

将XML的数据显示出来

发表于2004/9/27 13:01:00  775人阅读

VB/Global.asax Font Size:
C# Source: CS/Global.asax   CS/Application2.aspx   CS/SchemaData.xml   
VB Source: VB/Global.asax   VB/Application2.aspx   VB/SchemaData.xml   
JScript Source: JS/Global.asax   JS/Application2.aspx   JS/SchemaData.xml   
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.IO" %>

<script language="VB" runat="server">

    Sub Application_Start(Sender As Object, E As EventArgs)
    
        Dim DS As New DataSet

        Dim FS As FileStream

        FS = New FileStream(Server.MapPath("schemadata.xml"),FileMode.Open,FileAccess.Read)
        Dim Reader As StreamReader
        Reader = New StreamReader(FS)
        DS.ReadXml(Reader)
        FS.Close()

        Dim View As DataView
        View = New DataView(ds.Tables(0))
        Application("Source") = View
    End Sub

</script>






============
VB/Application2.aspx Font Size:
C# Source: CS/Global.asax   CS/Application2.aspx   CS/SchemaData.xml   
VB Source: VB/Global.asax   VB/Application2.aspx   VB/SchemaData.xml   
JScript Source: JS/Global.asax   JS/Application2.aspx   JS/SchemaData.xml   
<%@ Import Namespace="System.Data" %>

<html>
 

  <script language="VB" runat="server">

      Sub Page_Load(Src As Object, E As EventArgs)
      
          Dim Source As DataView = Application("source")
          MySpan.Controls.Add(New LiteralControl(Source.Table.TableName))
          MyDataGrid.DataSource = Source
          MyDataGrid.DataBind()
      End Sub

  </script>

<body>

  <h3><font face="宋体">读取 Application_OnStart 中的数据</font></h3>
  <h4><font face="宋体">表的 XML 数据<asp:PlaceHolder runat="server" id="MySpan"/></font></h4>

  <ASP:DataGrid id="MyDataGrid" runat="server"
    Width="900"
    BackColor="#ccccff" 
    BorderColor="black"
    ShowFooter="false" 
    CellPadding=3 
    CellSpacing="0"
    Font-Name="宋体"
    Font-Size="8pt"
    HeaderStyle-BackColor="#aaaadd"
    EnableViewState="false"
  />

</body>
</html>

=============
VB/SchemaData.xml Font Size:
C# Source: CS/Global.asax   CS/Application2.aspx   CS/SchemaData.xml   
VB Source: VB/Global.asax   VB/Application2.aspx   VB/SchemaData.xml   
JScript Source: JS/Global.asax   JS/Application2.aspx   JS/SchemaData.xml   
              <NewDataSet>
  <xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
    <xs:element name="NewDataSet" msdata:IsDataSet="true">
      <xs:complexType>
        <xs:choice maxOccurs="unbounded">
          <xs:element name="Table">
            <xs:complexType>
              <xs:sequence>
                <xs:element name="ProductID" type="xs:int" minOccurs="0" />
                <xs:element name="CategoryID" type="xs:int" minOccurs="0" />
                <xs:element name="ProductName" type="xs:string" minOccurs="0" />
                <xs:element name="ProductDescription" type="xs:string" minOccurs="0" />
                <xs:element name="UnitPrice" type="xs:decimal" minOccurs="0" />
                <xs:element name="ImagePath" type="xs:string" minOccurs="0" />
                <xs:element name="ServingSize" type="xs:string" minOccurs="0" />
                <xs:element name="Servings" type="xs:int" minOccurs="0" />
                <xs:element name="Quantity" type="xs:int" minOccurs="0" />
                <xs:element name="MinOnHand" type="xs:int" minOccurs="0" />
                <xs:element name="MaxOnHand" type="xs:int" minOccurs="0" />
                <xs:element name="Manufacturer" type="xs:string" minOccurs="0" />
              </xs:sequence>
            </xs:complexType>
          </xs:element>
        </xs:choice>
      </xs:complexType>
    </xs:element>
  </xs:schema>
  <Table>
    <ProductID>1001</ProductID>
    <CategoryID>1</CategoryID>
    <ProductName>Chocolate City Milk</ProductName>
    <ProductDescription>Chocolate City Milk Description</ProductDescription>
    <UnitPrice>2</UnitPrice>
    <ImagePath>/quickstart/aspplus/images/milk5.gif</ImagePath>
    <ServingSize>8 fl oz (240 mL)</ServingSize>
    <Servings>8</Servings>
    <Quantity>0</Quantity>
    <MinOnHand>0</MinOnHand>
    <MaxOnHand>0</MaxOnHand>
    <Manufacturer>Chocolate City</Manufacturer>
  </Table>
  <Table>
    <ProductID>1002</ProductID>
    <CategoryID>1</CategoryID>
    <ProductName>Bessie Brand 2% Milk</ProductName>
    <ProductDescription>Bessie Brand 2% Milk Description</ProductDescription>
    <UnitPrice>1.19</UnitPrice>
    <ImagePath>/quickstart/aspplus/images/milk1.gif</ImagePath>
    <ServingSize>8 fl oz (240 mL)</ServingSize>
    <Servings>8</Servings>
    <Quantity>0</Quantity>
    <MinOnHand>0</MinOnHand>
    <MaxOnHand>0</MaxOnHand>
    <Manufacturer>Milk Factory</Manufacturer>
  </Table>
  <Table>
    <ProductID>1003</ProductID>
    <CategoryID>1</CategoryID>
    <ProductName>Funny Farms  Milk</ProductName>
    <ProductDescription>Funny Farms Whole Milk Description</ProductDescription>
    <UnitPrice>1.29</UnitPrice>
    <ImagePath>/quickstart/aspplus/images/milk4.gif</ImagePath>
    <ServingSize>8 fl oz (240 mL)</ServingSize>
    <Servings>10</Servings>
    <Quantity>0</Quantity>
    <MinOnHand>0</MinOnHand>
    <MaxOnHand>0</MaxOnHand>
    <Manufacturer>Funny Farms</Manufacturer>
  </Table>
  <Table>
    <ProductID>2001</ProductID>
    <CategoryID>2</CategoryID>
    <ProductName>Fruity Pops</ProductName>
    <ProductDescription>Fruity Pops Description</ProductDescription>
    <UnitPrice>4.07</UnitPrice>
    <ImagePath>/quickstart/aspplus/images/cereal7.gif</ImagePath>
    <ServingSize>3/4 cup (30 g)</ServingSize>
    <Servings>17</Servings>
    <Quantity>0</Quantity>
    <MinOnHand>0</MinOnHand>
    <MaxOnHand>0</MaxOnHand>
    <Manufacturer>River Mills</Manufacturer>
  </Table>
  <Table>
    <ProductID>2002</ProductID>
    <CategoryID>2</CategoryID>
    <ProductName>U.F.O.s Cereal</ProductName>
    <ProductDescription>U.F.O.s Cereal Description</ProductDescription>
    <UnitPrice>3.34</UnitPrice>
    <ImagePath>/quickstart/aspplus/images/cereal3.gif</ImagePath>
    <ServingSize>1 cup (30 g)</ServingSize>
    <Servings>10</Servings>
    <Quantity>0</Quantity>
    <MinOnHand>0</MinOnHand>
    <MaxOnHand>0</MaxOnHand>
    <Manufacturer>Acme Harvesters</Manufacturer>
  </Table>
  <Table>
    <ProductID>2003</ProductID>
    <CategoryID>2</CategoryID>
    <ProductName>Healthy Grains</ProductName>
    <ProductDescription>Healthy Grains Cereal Description</ProductDescription>
    <UnitPrice>3.78</UnitPrice>
    <ImagePath>/quickstart/aspplus/images/cereal1.gif</ImagePath>
    <ServingSize>3/4 cup (30 g)</ServingSize>
    <Servings>17</Servings>
    <Quantity>0</Quantity>
    <MinOnHand>0</MinOnHand>
    <MaxOnHand>0</MaxOnHand>
    <Manufacturer>All Natural Co.</Manufacturer>
  </Table>
  <Table>
    <ProductID>2004</ProductID>
    <CategoryID>2</CategoryID>
    <ProductName>Super Sugar Strike</ProductName>
    <ProductDescription>Super Sugar Strike Description</ProductDescription>
    <UnitPrice>4.17</UnitPrice>
    <ImagePath>/quickstart/aspplus/images/cereal6.gif</ImagePath>
    <ServingSize>3/4 cup (30 g)</ServingSize>
    <Servings>17</Servings>
    <Quantity>0</Quantity>
    <MinOnHand>0</MinOnHand>
    <MaxOnHand>0</MaxOnHand>
    <Manufacturer>Capitol Cereals</Manufacturer>
  </Table>
  <Table>
    <ProductID>3001</ProductID>
    <CategoryID>3</CategoryID>
    <ProductName>Purple Rain</ProductName>
    <ProductDescription>Brown Barrel Root Beer Description</ProductDescription>
    <UnitPrice>1.1</UnitPrice>
    <ImagePath>/quickstart/aspplus/images/soda5.gif</ImagePath>
    <ServingSize>4 fl oz (120 mL)</ServingSize>
    <Servings>8</Servings>
    <Quantity>0</Quantity>
    <MinOnHand>0</MinOnHand>
    <MaxOnHand>0</MaxOnHand>
    <Manufacturer>BrainFade, Inc.</Manufacturer>
  </Table>
  <Table>
    <ProductID>3002</ProductID>
    <CategoryID>3</CategoryID>
    <ProductName>Extreme Orange</ProductName>
    <ProductDescription>Bargain Cola Description</ProductDescription>
    <UnitPrice>0.89</UnitPrice>
    <ImagePath>/quickstart/aspplus/images/soda6.gif</ImagePath>
    <ServingSize>6 fl oz (180 mL)</ServingSize>
    <Servings>6</Servings>
    <Quantity>0</Quantity>
    <MinOnHand>0</MinOnHand>
    <MaxOnHand>0</MaxOnHand>
    <Manufacturer>SuperX Beverages</Manufacturer>
  </Table>
  <Table>
    <ProductID>3003</ProductID>
    <CategoryID>3</CategoryID>
    <ProductName>Kona Diet Cola</ProductName>
    <ProductDescription>Super Red Pop Soda Description</ProductDescription>
    <UnitPrice>1.1</UnitPrice>
    <ImagePath>/quickstart/aspplus/images/soda7.gif</ImagePath>
    <ServingSize>4 fl oz (120 mL)</ServingSize>
    <Servings>10</Servings>
    <Quantity>0</Quantity>
    <MinOnHand>0</MinOnHand>
    <MaxOnHand>0</MaxOnHand>
    <Manufacturer>Kona Kola Co.</Manufacturer>
  </Table>
  <Table>
    <ProductID>3004</ProductID>
    <CategoryID>3</CategoryID>
    <ProductName>Fizzy Fizzing Drink</ProductName>
    <ProductDescription>Lemon Lime Quencher Description</ProductDescription>
    <UnitPrice>1.05</UnitPrice>
    <ImagePath>/quickstart/aspplus/images/soda8.gif</ImagePath>
    <ServingSize>6 fl oz (180 mL)</ServingSize>
    <Servings>5</Servings>
    <Quantity>0</Quantity>
    <MinOnHand>0</MinOnHand>
    <MaxOnHand>0</MaxOnHand>
    <Manufacturer>Sparkle Co.</Manufacturer>
  </Table>
  <Table>
    <ProductID>1005</ProductID>
    <CategoryID>1</CategoryID>
    <ProductName>Marigold Whole Milk</ProductName>
    <ProductDescription>Marigold Whole Milk Description</ProductDescription>
    <UnitPrice>1.39</UnitPrice>
    <ImagePath>/quickstart/aspplus/images/milk6.gif</ImagePath>
    <ServingSize>8 fl oz (240 mL)</ServingSize>
    <Servings>8</Servings>
    <Quantity>0</Quantity>
    <MinOnHand>0</MinOnHand>
    <MaxOnHand>0</MaxOnHand>
    <Manufacturer>Marigold Meadows</Manufacturer>
  </Table>
</NewDataSet>
                  

















阅读全文
0 0

相关文章推荐

img
取 消
img