⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xmldomread.aspx

📁 asp入门到精通的源代码
💻 ASPX
字号:
<%@ Page Language="VB" %>
<%@ Import Namespace="System.Xml" %>

<script runat=server>
   private i as integer
   private strOutput as string = ""
   
   sub Page_Load(obj as object, e as eventargs)
      dim xmldoc as new XMLDocument()
         
      try
         xmldoc.Load(Server.MapPath("books.xml"))
         ShowTree(xmldoc.DocumentElement)

         catch ex as Exception
            strOutput = "Error accessing XML file"
      end try
      
      output.Text = strOutput
   end sub
   
   sub ShowTree(node as XMLNode)
      Dim attrnode As XmlNode
      Dim map As XmlNamedNodeMap
		
      If Not(node.HasChildNodes)
         strOutput += "&nbsp;&nbsp;<b>" & node.Name & "</b> &lt;" & _
            node.Value & "&gt;<br>" & vbcrlf
      Else
         strOutput += "<b>" & node.Name & "</b>"
         If node.NodeType = XmlNodeType.Element Then
            map = node.Attributes
            For Each attrnode In map
               strOutput += " <b>" & attrnode.Name & "</b> &lt;" & _
                  attrnode.Value & "&gt; " & vbcrlf
            Next
         End If
         strOutput += "<br>"
      End If
      
      If node.HasChildNodes then
         node = node.FirstChild
         While not IsNothing(node)
            ShowTree(node)
            node = node.NextSibling
         end while
      end if
   end sub
</script>

<html><body>
   <asp:Label id="output" runat="server" />
</body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -