分享

请教如何使用VB导出XML文件

 玉雪龙山999 2012-02-15
'请教如何使用VB导出XML文件
''给你一段读写XML的源码供你参考,只能整个文件写,把记录集做个do until eof  写入就可以了
'Private Sub SaveXmlV(ByVal strNode As String)
'strNode:节点名称,strChild:分支名称,strValues:值

'SaveXmlV = False

'Dim xml_D As DOMDocument
'Dim values_Node As IXMLDOMNode

'Create the Values section node
'Set xml_D = New DOMDocument

'Create the Values section node.
'Set values_Node = xml_D.createElement(strNode)
'xml_D.appendChild values_Node

'Add the Values section node to the document
'xml_D.appendChild values_Node
'CreateNode 1, values_Node, "SqlServer", Trim(ServerText.Text)
'CreateNode 1, values_Node, "Account", Trim(ZtCombo.Text)
'CreateNode 1, values_Node, "AUTOCONN", IIf(chkConn.Value = 1, "T", "F")
'CreateNode 1, values_Node, "CZYNAME", Trim(CzyCombo.Text)
'xml_D.Save App.Path & stXml

'End Sub

'读取XML值
'Private Sub LoadXmlValues()

'Dim xml_D As DOMDocument
'Dim values_Node As IXMLDOMNode
'Dim int_Count As Integer
'Dim str_Account As String

'Set xml_D = New DOMDocument
'xml_D.Load App.Path & stXml

'If the file doesn't exist,then xml_d.documentsElement is Nothing
'If xml_D.documentElement Is Nothing Then
'    Exit Sub
'End If

'Find the Values section.
'Set values_Node = xml_D.selectSingleNode("Login")

'If values_Node Is Nothing Then Exit Sub

'Read the saved values.
'ServerText.Text = GetNodeValue(values_Node, "SqlServer", "")
'chkConn.Value = IIf(GetNodeValue(values_Node, "AUTOCONN", "") = "T", 1, 0)
'CzyCombo.Text = GetNodeValue(values_Node, "CZYNAME", "")
'CzyCombo.Tag = IIf(Trim(CzyCombo.Text) <> "", CzyCombo.Text, "")
'str_Account = GetNodeValue(values_Node, "Account", "")

'End Sub

'Private Sub CreateNode(ByVal indent As Integer, _
'  ByVal parent As IXMLDOMNode, ByVal node_Name As String, _
'  ByVal node_value As String)
 
'Dim new_node As IXMLDOMNode

'Indent.
'parent.appendChild parent.ownerDocument.createTextNode(Space$(indent))

'Create the new node.
'Set new_node = parent.ownerDocument.createElement(node_Name)

'Set the node's text value.
'new_node.Text = node_value

'Add the node to the parent.
'parent.appendChild new_node

'Add a new line.
'parent.appendChild parent.ownerDocument.createTextNode(vbCrLf)
'End Sub

'Return the node's value.
'Private Function GetNodeValue(ByVal start_at_node As IXMLDOMNode, _
'ByVal node_Name As String, _
'Optional ByVal default_value As String = "") As String

'Dim value_Node As IXMLDOMNode

'Set value_Node = start_at_node.selectSingleNode(".//" & node_Name)
'If value_Node Is Nothing Then
'    GetNodeValue = default_value
'Else
'    GetNodeValue = value_Node.Text
'End If
'End Function
''楼上代码好玩. 从头注释到尾
''当初图新鲜用xml,后来觉得用得不太顺手,又改成读写ini,所以就把它们都注释掉了.不过那段代码是调试过可用的

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多