以文本方式查看主题

-  中文XML论坛 - 专业的XML技术讨论区  (http://bbs.xml.org.cn/index.asp)
--  『 DTD/XML Schema 』  (http://bbs.xml.org.cn/list.asp?boardid=23)
----  我的这段程序是什么意思啊  (http://bbs.xml.org.cn/dispbbs.asp?boardid=23&rootid=&id=32556)


--  作者:bonwezhou
--  发布时间:5/17/2006 1:40:00 PM

--  我的这段程序是什么意思啊
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



--  作者:chafer0516
--  发布时间:5/17/2006 2:26:00 PM

--  
看起来似乎是用DOM技术实现的XML文档的读取问题。
本人对VB无能为力
你多看看DOM的资料应该能明白吧
本人也才开始学习XML
--  作者:bonwezhou
--  发布时间:5/17/2006 2:29:00 PM

--  
谢谢你回帖~~~~
W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
3,093.750ms