VB.NET2005读取XML数据
通过调用CreateDataSetfromXml取得XML数据
Imports System.Xml
Public Const FILE_CONFIG = "MZZ.xml"
Public Const PATH_CONFIG = "\XML\"
Dim dstXML As DataSet
Dim tblXML_DB As DataTable
Dim dtCod As New DataTable
Dim strSQL As String = ""
clsPublic.pstrAppPath = System.Windows.Forms.Application.StartupPath'启动程序路径
'启动程序上级目录(InStrRev是取得最后显示\的位置)
clsPublic.pstrAppPath = Mid(clsPublic.pstrAppPath, 1, InStrRev(clsPublic.pstrAppPath, "\", ) - 1)
'只能启动一个程序
If UBound(Diagnostics.Process.GetProcessesByName(Diagnostics.Process.GetCurrentProcess.ProcessName)) > 0 Then
Exit Sub
End If
'读取XML数据(QDIS节点,作为一个table,所以是dstXML.Tables(0))
dstXML = CreateDataSetfromXml(FILE_CONFIG)
tblXML_DB = dstXML.Tables(0)
clsDBBase.Uid = tblXML_DB.Rows(0).Item("UserId")
clsDBBase.Psw = tblXML_DB.Rows(0).Item("Password")
clsDBBase.Dsn = tblXML_DB.Rows(0).Item("DataSource")
'(APPL节点,作为一个table,所以是dstXML.Tables(1))
clsPublic.Timer_Interval = CType(dstXML.Tables(1).Rows(0).Item("Interval"), Integer)
'内存整理
GC.Collect()
Public Function CreateDataSetfromXml(ByVal strFileName As String) As DataSet
Dim xmlDoc As XmlDataDocument = New XmlDataDocument
Dim xmlReader As StreamReader = Nothing
Try
xmlReader = New StreamReader(clsPublic.pstrAppPath & PATH_CONFIG & strFileName)
xmlDoc.DataSet.ReadXml(xmlReader, XmlReadMode.Auto)
Return xmlDoc.DataSet.Copy
Catch ex As Exception
Return Nothing
Finally
Try
If Not xmlReader Is Nothing Then
xmlReader.Close()
xmlReader = Nothing
End If
相关文档:
Introduction
This article is about passing data between VB.NET/C# WinForms and JavaScript.
Before reading further, let me warn you that this article is not about ASP.NET. Concepts covered in the article are applied to Desktop applications.
Background
I was working on a project which required dat ......
已知有一个XML文件(bookstore.xml)如下:
<?xml version="1.0" encoding="gb2312"?>
<bookstore>
<book genre="fantasy" ISBN="2-3631-4">
<title>Oberon's Legacy</title>
<author>Corets, Eva</author>
&nb ......
1 类似xmlns=""的文件
示例XML文件:
<?xml version="1.0" encoding="UTF-8"?>
<WebSrvMessage xmlns="http://www.lenoval.com/">
<version>1.0</version>
<DataContent>
<DateTag>2010-5-17</DateTag>
</DataCont ......
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Xml;
using System.Text; ......
最近在利用vb编写关于百度空间验证码自动识别的程序,但是一直没能实现,原因就是我的水平还是太菜。于是从网上寻找了很多关于验证码识别的源代码,从里面学到不少东西,算是没白努力吧。在此总结一下学到的东西,希望能对朋友们有些帮助吧。
首先整理下编写验证码识别的思路吧:
1 ......