markdown测试:VB代码着色
VB代码着色效果测试:
Option Explicit
Private document As DOMDocument
Private action As IXMLDOMElement
Public Property Let xml(ByVal xml As String)
Set document = New DOMDocument
document.loadXML xml
'document.Load App.Path + "\from.xml"
Set action = document.selectSingleNode("action")
End Property
Function getNodeAttribute(ByVal attribute_name As String)
Dim element As IXMLDOMElement
Set element = action
If element Is Nothing Then
getNodeAttribute = ""
Else
getNodeAttribute = element.getAttribute(attribute_name)
End If
End Function
Function getNodeValue(ByVal node_name As String)
Dim node As IXMLDOMNode
Set node = action.selectSingleNode(node_name)
If node Is Nothing Then
getNodeValue = ""
Else
getNodeValue = node.Text
End If
End Function
Public Sub createDocument(ByVal name As String)
Set document = New DOMDocument
Set action = document.createElement("action")
action.setAttribute "name", name
document.appendChild action
End Sub
Public Sub appendNode(ByVal node_name As String, ByVal node_value As String)
Dim node As IXMLDOMNode
Set node = action.ownerDocument.createElement(node_name)
node.Text = node_value
action.appendChild node
End Sub
Public Property Get xml() As String
xml = document.xml
'document.save App.Path + "\to.xml"
End Property
调用程序如下:
Option Explicit
Private Sub Form_Load()
Dim obj As New ClsXml
obj.xml = "<action name=""login""><username>a</username><password>1</password></action>"
MsgBox obj.getNodeAttribute("name")
MsgBox obj.getNodeValue("username")
MsgBox obj.getNodeValue("password")
obj.createDocument "logout"
obj.appendNode "username", "a"
obj.appendNode "password", "1"
MsgBox obj.xml
Unload Me
End Sub
代码来自:http://www.cnblogs.com/happy-wangtao/archive/2006/12/24/602030.html
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 理解Rust引用及其生命周期标识(下)
· 从二进制到误差:逐行拆解C语言浮点运算中的4008175468544之谜
· .NET制作智能桌面机器人:结合BotSharp智能体框架开发语音交互
· 软件产品开发中常见的10个问题及处理方法
· .NET 原生驾驭 AI 新基建实战系列:向量数据库的应用与畅想
· 2025成都.NET开发者Connect圆满结束
· 后端思维之高并发处理方案
· 在 VS Code 中,一键安装 MCP Server!
· 千万级大表的优化技巧
· 用一种新的分类方法梳理设计模式的脉络
2013-07-23 云计算之路-阿里云上-阵雨:RDS故障的突袭
2012-07-23 上周热点回顾(7.16-7.22)
2010-07-23 【博客园】用户身份小调查!