新网创想网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

vb点虐 node的简单介绍

vb点虐 如何操作xml的element和node?

Public Function WriteConfigInfo(ByVal aSection As String, ByVal aKey As String, _

让客户满意是我们工作的目标,不断超越客户的期望值来自于我们对这个行业的热爱。我们立志把好的技术通过有效、简单的方式提供给客户,将通过不懈努力成为客户在信息化领域值得信任、有价值的长期合作伙伴,公司提供的服务项目有:域名申请雅安服务器托管、营销软件、网站建设、额济纳网站维护、网站推广。

ByVal aValue As String, ByVal aFileName As String) As Boolean

If aSection = "" Then Return False

If aFileName = "" Then Return (False)

' create in instance of the class and write the config file info

Dim XmlFile As New clsXMLCfgFile(aFileName)

Return XmlFile.WriteConfigInfo(aSection, aKey, aValue)

End Function

Public Class clsXMLCfgFile

Dim Doc As New XmlDocument()

Dim FileName As String

Dim doesExist As Boolean

Public Sub New(ByVal aFileName As String)

FileName = aFileName

Try

Doc.Load(aFileName)

doesExist = True

Catch ex As Exception

If Err.Number = 53 Then

Doc.LoadXml(("configuration" "/configuration"))

Doc.Save(aFileName)

End If

End Try

End Sub

Public Function GetConfigInfo(ByVal aSection As String, ByVal aKey As String, ByVal aDefaultValue As String) As Collection

' return immediately if the file didn't exist

If doesExist = False Then

Return New Collection()

End If

If aSection = "" Then

' if aSection = "" then get all section names

Return getchildren("")

ElseIf aKey = "" Then

' if aKey = "" then get all keynames for the section

Return getchildren(aSection)

Else

Dim col As New Collection()

col.Add(getKeyValue(aSection, aKey, aDefaultValue))

Return col

End If

End Function

Public Function WriteConfigInfo(ByVal aSection As String, ByVal aKey As String, ByVal aValue As String) As Boolean

Dim node1 As XmlNode

Dim node2 As XmlNode

If aKey = "" Then

' find the section, remove all its keys and remove the section

node1 = (Doc.DocumentElement).SelectSingleNode("/configuration/" aSection)

' if no such section, return True

If node1 Is Nothing Then Return True

' remove all its children

node1.RemoveAll()

' select its parent ("configuration")

node2 = (Doc.DocumentElement).SelectSingleNode("configuration")

' remove the section

node2.RemoveChild(node1)

ElseIf aValue = "" Then

' find the section of this key

node1 = (Doc.DocumentElement).SelectSingleNode("/configuration/" aSection)

' return if the section doesn't exist

If node1 Is Nothing Then Return True

' find the key

node2 = (Doc.DocumentElement).SelectSingleNode("/configuration/" aSection "/" aKey)

' return true if the key doesn't exist

If node2 Is Nothing Then Return True

' remove the key

If node1.RemoveChild(node2) Is Nothing Then Return False

Else

' Both the Key and the Value are filled

' Find the key

node1 = (Doc.DocumentElement).SelectSingleNode("/configuration/" aSection "/" aKey)

If node1 Is Nothing Then

' The key doesn't exist: find the section

node2 = (Doc.DocumentElement).SelectSingleNode("/configuration/" aSection)

If node2 Is Nothing Then

' Create the section first

Dim e As Xml.XmlElement = Doc.CreateElement(aSection)

' Add the new node at the end of the children of ("configuration")

node2 = Doc.DocumentElement.AppendChild(e)

' return false if failure

If node2 Is Nothing Then Return False

' now create key and value

e = Doc.CreateElement(aKey)

e.InnerText = aValue

' Return False if failure

If (node2.AppendChild(e)) Is Nothing Then Return False

Else

' Create the key and put the value

Dim e As Xml.XmlElement = Doc.CreateElement(aKey)

e.InnerText = aValue

node2.AppendChild(e)

End If

Else

' Key exists: set its Value

node1.InnerText = aValue

End If

End If

' Save the document

Doc.Save(FileName)

Return True

End Function

Private Function getKeyValue(ByVal aSection As String, ByVal aKey As String, ByVal aDefaultValue As String) As String

Dim node As XmlNode

node = (Doc.DocumentElement).SelectSingleNode("/configuration/" aSection "/" aKey)

If node Is Nothing Then Return aDefaultValue

Return node.InnerText

End Function

Private Function getchildren(ByVal aNodeName As String) As Collection

Dim col As New Collection()

Dim node As XmlNode

Try

' Select the root if the Node is empty

If aNodeName = "" Then

node = Doc.DocumentElement

Else

' Select the node given

node = Doc.DocumentElement.SelectSingleNode(aNodeName)

End If

Catch

End Try

' exit with an empty collection if nothing here

If node Is Nothing Then Return col

' exit with an empty colection if the node has no children

If node.HasChildNodes = False Then Return col

' get the nodelist of all children

Dim nodeList As XmlNodeList = node.ChildNodes

Dim i As Integer

' transform the Nodelist into an ordinary collection

For i = 0 To nodeList.Count - 1

col.Add(nodeList.Item(i).Name)

Next

Return col

End Function

End Class

Top

把它放模块中,稍微调试一下:)就OK了

VB.NET中怎么给TreeView的父节点添加相对应的子节点?求助各位!

Public Class Form1

Dim node(5) As TreeNode

Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

  Dim root As TreeNode

  With TreeView1

      .Nodes.Clear()

      .ShowLines = True

      .ShowPlusMinus = True

      .ShowRootLines = True

      root = .Nodes.Add("仓库") '增加根节点

      .SelectedNode = root  '在此根节点下添加子节点

      For i = 1 To 6

          node(i - 1) = .SelectedNode.Nodes.Add(i.ToString  "号仓库")

      Next

      .ExpandAll()

  End With

End Sub

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click

  If Val(TextBox1.Text) = 100 And Val(TextBox1.Text) = 699 Then

      node(Val(TextBox1.Text) \ 100 - 1).Nodes.Add(TextBox1.Text)

  End If

End Sub

Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click

  If Val(TextBox2.Text) = 1000000 And Val(TextBox2.Text) = 6999999 Then

      For Each child As TreeNode In node(Val(TextBox2.Text) \ 1000000 - 1).Nodes

          If child.Text = TextBox2.Text.Substring(1, 3) Then

              child.Nodes.Add(TextBox2.Text)

              Exit For

          End If

      Next

  End If

End Sub

End Class

VB.Net 前后端分离怎么实现的

1.一般来说,要实现前后端分离,前端就需要开启一个本地的服务器来运行自己的前端代码,以此来模拟真实的线上环境,并且,也是为了更好的开发。因为你在实际开发中,你不可能要求每一个前端都去搭建一个java(php)环境,并且在java环境下开发,这对于前端来说,学习成本太高了。

?2.但如果本地没有开启服务器的话,不仅无法模拟线上的环境,而且还面临到了跨域的问题,因为你如果写静态的html页面,直接在文件目录下打开的话,你是无法发出ajax请求的(浏览器跨域的限制),因此,你需要在本地运行一个服务器,可是又不想搭建陌生而庞大的java环境,怎么办法呢?nodejs正好解决了这个问题。在我们项目中,我们利用nodejs的express框架来开启一个本地的服务器,然后利用nodejs的一个http-proxy-middleware插件将客户端发往nodejs的请求转发给真正的服务器,让nodejs作为一个中间层。这样,前端就可以无忧无虑的开发了

?3.由于前后端分离后,前端和后台同时开发时,就可能遇到前端已经开发好一个页面了,可是却等待后台API接口的情况。比如说A是负责前端,B是负责后台,A可能用了一周做好了基本的结构,并且需要API接口联调后,才能继续开发,

?4.而此时B却还没有实现好所需要的接口,这种情况,怎么办呢?在我们这个项目里,我们是通过了mock来提供一些假数据,我们先规定好了API接口,设计出了一套API文档,然后我们就可以通过API文档,利用mock来返回一些假数据,这样就可以模拟发送API到接受响应的整一个过程,

?5.因此前端也不需要依赖于后端开发了,可以独立开发,等到后台的API全部设计完之后,就可以比较快速的联调。


文章标题:vb点虐 node的简单介绍
本文URL:http://www.wjwzjz.com/article/ddjpisg.html
在线咨询
服务热线
服务热线:028-86922220
TOP