Dim w As String
Dim q As String
Dim s As Integer
Public Sub TravelNode(ByRef Nodes As MSXML.IXMLDOMNodeList, ByVal Indent As Integer)
Dim xNode As MSXML.IXMLDOMNode
Indent = Indent + 2
For Each xNode In Nodes
If xNode.nodeType = NODE_TEXT Then
Dim j As String
j = xNode.parentNode.nodeName
If w = j Then
If Trim(xNode.nodeValue) = "*" Then
q = ""
Else: q = xNode.nodeValue
End If
End If
Exit Sub
ElseIf xNode.hasChildNodes Then
TravelNode xNode.childNodes, Indent
End If
Next xNode
End Sub
Private Sub Command1_Click()
CommonDialog1.CancelError = True
On Error GoTo ErrHandler
CommonDialog1.Flags = cdlOFNHideReadOnly
CommonDialog1.Filter = "DTD文件是: (*.dtd)|*.dtd|Text Files" & "(*.txt)|*.txt|Batch Files (*.bat)|*.bat"
CommonDialog1.FilterIndex = 2
CommonDialog1.ShowOpen
Text1.Text = CommonDialog1.FileName
Exit Sub
ErrHandler:
Exit Sub
End Sub
Private Sub Command2_Click()
Dim str1 As String
Dim a As String
FileName = CommonDialog1.FileName
Open FileName For Input As #1
Open "C:\Documents and Settings\advstu\桌面\bysj.txt" For Output As #2
MsgBox "提交DTD文件完成,请稍候!"
Do While Not EOF(1)
Line Input #1, str1
'If InStr(str1, "<!ELENMENT >") = 0 Then
Print #2, str1
Else
b = Len(str1)
pos = InStr(str1, "<!ELENMENT >")
a = Mid(str1, pos + 2, b - pos - 3)
w = a
Call LoadDocument
Print #2, q
End If
Loop
Close #1
Close #2
inputdialog.Show 1
Exit Sub
End Sub
Public Sub LoadDocument()
Dim xDoc As MSXML.DOMDocument
Set xDoc = New MSXML.DOMDocument
xDoc.validateOnParse = False
If xDoc.Load("Text1.Text") Then
TravelNode xDoc.childNodes, 0
Else
MsgBox ("引导文档出错!")
End If
End Sub
Private Sub Command3_Click()
End
End Sub