Option Explicit
'makes it necessary to specify variables
'and makes sure no variable used twice
Private Function CreateDOM()
Dim dom
Set dom = New DOMDocument30
dom.async = False
dom.validateOnParse = False
dom.resolveExternals = False
dom.preserveWhiteSpace = True
Set CreateDOM = dom
End Function
Private Sub File1_Click()
Dim dom, node, frag, cd, attr
On Error GoTo ErrorHandler
Set dom = CreateDOM
' Create a processing instruction targeted for xml.
Set node = dom.createProcessingInstruction("xml", "version='1.0' encoding='UTF-8'")
dom.appendChild node
Set node = Nothing
' Create a comment for the document.
Set node = dom.createComment("sample xml file created using XML DOM object.")
dom.appendChild node
Set node = Nothing
' Create the root element.
Dim root
Set root = dom.createElement("videos")
' Add the root element to the DOM instance.
dom.appendChild root
' Insert a newline + tab.
root.appendChild dom.createTextNode(vbNewLine + vbTab)
' Create and add more nodes to the root element just created.
' Create a text element.
Set node = dom.createElement("video")
'node.Text = "some character data"
node.Text = File1.FileName
' Add text node to the root element.
root.appendChild node
Set node = Nothing
' Add a newline plus tab.
root.appendChild dom.createTextNode(vbNewLine + vbTab)
' Save the XML document to a file.
dom.save App.Path + "\flv.xml"
Set root = Nothing
Set dom = Nothing
Exit Sub
ErrorHandler:
MsgBox Err.Description
End Sub
Private Sub Form_Load()
'play shockwav movie
ShockwaveFlash1.Movie = App.Path & "\XML_FLV_player.swf"
End Sub
'search for flv file
Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub
Private Sub Dir1_Change()
File1.Path = Dir1.Path
File1.Pattern = "*.flv"
End Sub