home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 4_2005-2006.ISO / data / Zips / XML_Parser19555112102005.psc / forms / frmMain.frm < prev    next >
Text File  |  2005-12-10  |  19KB  |  623 lines

  1. VERSION 5.00
  2. Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
  3. Object = "{3B7C8863-D78F-101B-B9B5-04021C009402}#1.2#0"; "RICHTX32.OCX"
  4. Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
  5. Begin VB.Form frmMain 
  6.    Caption         =   "Code Collector"
  7.    ClientHeight    =   5775
  8.    ClientLeft      =   165
  9.    ClientTop       =   555
  10.    ClientWidth     =   8670
  11.    Icon            =   "frmMain.frx":0000
  12.    LinkTopic       =   "Form1"
  13.    MDIChild        =   -1  'True
  14.    ScaleHeight     =   5775
  15.    ScaleWidth      =   8670
  16.    Begin MSComctlLib.ImageList imgl 
  17.       Left            =   3840
  18.       Top             =   3720
  19.       _ExtentX        =   1005
  20.       _ExtentY        =   1005
  21.       BackColor       =   -2147483643
  22.       ImageWidth      =   16
  23.       ImageHeight     =   16
  24.       MaskColor       =   12632256
  25.       _Version        =   393216
  26.       BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
  27.          NumListImages   =   3
  28.          BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  29.             Picture         =   "frmMain.frx":06EA
  30.             Key             =   "closed"
  31.          EndProperty
  32.          BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  33.             Picture         =   "frmMain.frx":0C84
  34.             Key             =   "open"
  35.          EndProperty
  36.          BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  37.             Picture         =   "frmMain.frx":121E
  38.             Key             =   "selected"
  39.          EndProperty
  40.       EndProperty
  41.    End
  42.    Begin MSComDlg.CommonDialog cd 
  43.       Left            =   3840
  44.       Top             =   2640
  45.       _ExtentX        =   847
  46.       _ExtentY        =   847
  47.       _Version        =   393216
  48.       CancelError     =   -1  'True
  49.       Filter          =   "XML Files (*.xml)|*.xml"
  50.    End
  51.    Begin RichTextLib.RichTextBox txtXML 
  52.       Height          =   5535
  53.       Left            =   4080
  54.       TabIndex        =   1
  55.       Top             =   120
  56.       Width           =   4455
  57.       _ExtentX        =   7858
  58.       _ExtentY        =   9763
  59.       _Version        =   393217
  60.       ReadOnly        =   -1  'True
  61.       ScrollBars      =   3
  62.       Appearance      =   0
  63.       AutoVerbMenu    =   -1  'True
  64.       TextRTF         =   $"frmMain.frx":17B8
  65.    End
  66.    Begin MSComctlLib.TreeView tvXML 
  67.       Height          =   5535
  68.       Left            =   120
  69.       TabIndex        =   0
  70.       Top             =   120
  71.       Width           =   3855
  72.       _ExtentX        =   6800
  73.       _ExtentY        =   9763
  74.       _Version        =   393217
  75.       HideSelection   =   0   'False
  76.       PathSeparator   =   "/"
  77.       Style           =   7
  78.       ImageList       =   "imgl"
  79.       BorderStyle     =   1
  80.       Appearance      =   0
  81.    End
  82.    Begin VB.Menu mnuFile 
  83.       Caption         =   "&File"
  84.       Begin VB.Menu mnuFileNew 
  85.          Caption         =   "&New XML"
  86.          Shortcut        =   ^N
  87.       End
  88.       Begin VB.Menu mnuFileOpen 
  89.          Caption         =   "&Open XML..."
  90.          Shortcut        =   ^O
  91.       End
  92.       Begin VB.Menu mnuFileClose 
  93.          Caption         =   "&Close"
  94.       End
  95.       Begin VB.Menu sep1 
  96.          Caption         =   "-"
  97.       End
  98.       Begin VB.Menu mnuFileSave 
  99.          Caption         =   "&Save"
  100.          Shortcut        =   ^S
  101.       End
  102.       Begin VB.Menu mnuFileSaveAs 
  103.          Caption         =   "Save &As..."
  104.       End
  105.       Begin VB.Menu sep2 
  106.          Caption         =   "-"
  107.       End
  108.       Begin VB.Menu mnuFileExit 
  109.          Caption         =   "E&xit"
  110.       End
  111.    End
  112.    Begin VB.Menu mnuTools 
  113.       Caption         =   "&Tools"
  114.       Begin VB.Menu mnuToolsFont 
  115.          Caption         =   "&Font..."
  116.       End
  117.    End
  118.    Begin VB.Menu mnuNode 
  119.       Caption         =   "&Node"
  120.       Visible         =   0   'False
  121.       Begin VB.Menu mnuNodeDelete 
  122.          Caption         =   "&Delete"
  123.       End
  124.       Begin VB.Menu mnuNodeAdd 
  125.          Caption         =   "&Add Child"
  126.       End
  127.    End
  128.    Begin VB.Menu mnuWindow 
  129.       Caption         =   "&Window"
  130.       WindowList      =   -1  'True
  131.       Begin VB.Menu mnuTileHori 
  132.          Caption         =   "Tile &Horizontal"
  133.       End
  134.       Begin VB.Menu mnuTileVert 
  135.          Caption         =   "Tile &Vertical"
  136.       End
  137.       Begin VB.Menu mnuWindowCascade 
  138.          Caption         =   "&Cascade"
  139.       End
  140.       Begin VB.Menu mnuWIcons 
  141.          Caption         =   "&Arrange Icons"
  142.       End
  143.    End
  144.    Begin VB.Menu mnuHelp 
  145.       Caption         =   "&Help"
  146.       Begin VB.Menu mnuHelpAbout 
  147.          Caption         =   "&About..."
  148.       End
  149.    End
  150. End
  151. Attribute VB_Name = "frmMain"
  152. Attribute VB_GlobalNameSpace = False
  153. Attribute VB_Creatable = False
  154. Attribute VB_PredeclaredId = True
  155. Attribute VB_Exposed = False
  156. Option Explicit
  157.  
  158. Dim FileName As String
  159. Dim bFileDirty As Boolean, bInFocus As Boolean, bDirty As Boolean
  160. Dim doc As DOMDocument40
  161. Dim xNode As node
  162. Dim inDrag As Boolean
  163.  
  164. Private Sub initDoc()
  165.     'init doc object. Check out the docs
  166.     Set doc = New DOMDocument40
  167.     doc.async = False
  168.     doc.validateOnParse = False
  169.     doc.resolveExternals = False
  170. End Sub
  171.  
  172. 'called when xml file opened
  173. 'to fill the tree with doc object and its child nodes
  174. Private Sub AddAllNodes(iNode As DOMDocument40)
  175. Dim iNodes As IXMLDOMNodeList
  176. Dim i As Integer
  177.  
  178.     'this(document object) is the parent of root node, so just recurse (dont add)
  179.     Set iNodes = iNode.childNodes
  180.     'in case if there are more than 1 root node (not supported now)
  181.     For i = 0 To iNodes.length - 1
  182.         AddNodes iNodes(i)
  183.     Next
  184.     'Select the first node if present
  185.     If tvXML.Nodes.Count > 0 Then tvXML_NodeClick tvXML.Nodes(1)
  186. End Sub
  187.  
  188. 'recursively adds child nodes to the tree
  189. Private Sub AddNodes(iNode As IXMLDOMNode, Optional rel As node)
  190. Dim iNodes As IXMLDOMNodeList
  191. Dim i As Integer
  192. Dim thisnode As node
  193.  
  194.     'Debug.Print iNode.nodeName & ": " & iNode.nodeType
  195.     If iNode.nodeType <> 1 Then Exit Sub 'only of type element is accepted!
  196.  
  197.     If rel Is Nothing Then 'root node
  198.         Set thisnode = tvXML.Nodes.Add(, tvwChild, , iNode.nodeName, , "selected")
  199.     Else 'child of rel
  200.         Set thisnode = tvXML.Nodes.Add(rel, tvwChild, , iNode.nodeName, , "selected")
  201.     End If
  202.     'set treenode images
  203.     thisnode.Image = "closed"
  204.     thisnode.ExpandedImage = "open"
  205.  
  206.     'recurse
  207.     Set iNodes = iNode.childNodes
  208.     For i = 0 To iNodes.length - 1
  209.         AddNodes iNodes(i), thisnode
  210.     Next
  211. End Sub
  212.  
  213. Private Sub Form_Load()
  214.     'load the font settings
  215.     With txtXML.Font
  216.         .Name = GetSetting(App.Title, "Font", "Name", "Arial")
  217.         .Size = GetSetting(App.Title, "Font", "Size", 9)
  218.         .Bold = GetSetting(App.Title, "Font", "Bold", False)
  219.         .Italic = GetSetting(App.Title, "Font", "Italic", False)
  220.         .Strikethrough = GetSetting(App.Title, "Font", "Strikethrough", False)
  221.         .Underline = GetSetting(App.Title, "Font", "Underline", False)
  222.     End With
  223.     'initialize
  224.     Call initDoc
  225.     'if file is not opened then create new file
  226.     If FileName = "" Then
  227.         FileName = "Untitled.xml"
  228.     Else
  229.         'open the file
  230.         doc.Load FileName
  231.         AddAllNodes doc
  232.     End If
  233.     SetFileClean
  234. End Sub
  235.  
  236. 'just set the filename to the received file
  237. 'actual opening will be done in form load
  238. Public Sub OpenXML(s As String)
  239.     FileName = s
  240. End Sub
  241.  
  242. 'change the caption according to file's cleaness
  243. Sub SetFileClean()
  244.     bFileDirty = False
  245.     Caption = FileName
  246. End Sub
  247.  
  248. Sub SetFileDirty()
  249.     bFileDirty = True
  250.     Caption = FileName & "*"
  251. End Sub
  252.  
  253. 'the usual yes/no/cancel
  254. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
  255. Dim ret As VbMsgBoxResult
  256.  
  257.     txtXML_LostFocus 'check if node text changed
  258.     If bFileDirty Then
  259.         ret = MsgBox("Save '" & FileName & "'", vbYesNoCancel, App.Title)
  260.         If ret = vbYes Then
  261.             Cancel = Not SaveFile 'if user clicked cancel in SaveAs Box
  262.         ElseIf ret = vbCancel Then
  263.             Cancel = True
  264.         End If
  265.     End If
  266. End Sub
  267.  
  268. 'resize the controls
  269. Private Sub Form_Resize()
  270.     If ScaleHeight < 240 Then Exit Sub 'escape error
  271.     'both treeview and txtbox take half of the form
  272.     tvXML.Move 120, 120, ScaleWidth / 2 - 240, ScaleHeight - 240
  273.     txtXML.Move ScaleWidth / 2, 120, ScaleWidth / 2 - 120, ScaleHeight - 240
  274. End Sub
  275.  
  276. 'clean up
  277. Private Sub Form_Unload(Cancel As Integer)
  278.     Set doc = Nothing
  279.     'save the font settings
  280.     With txtXML.Font
  281.         SaveSetting App.Title, "Font", "Name", .Name
  282.         SaveSetting App.Title, "Font", "Size", .Size
  283.         SaveSetting App.Title, "Font", "Bold", .Bold
  284.         SaveSetting App.Title, "Font", "Italic", .Italic
  285.         SaveSetting App.Title, "Font", "Strikethrough", .Strikethrough
  286.         SaveSetting App.Title, "Font", "Underline", .Underline
  287.     End With
  288. End Sub
  289.  
  290. Private Sub mnuFileClose_Click()
  291.     Unload Me
  292. End Sub
  293.  
  294. 'transfer these to mdi
  295. Private Sub mnuFileExit_Click()
  296.     mdiMain.mnuFileExit_Click
  297. End Sub
  298.  
  299. Private Sub mnuFileNew_Click()
  300.     mdiMain.NewFile
  301. End Sub
  302.  
  303. Private Sub mnuFileOpen_Click()
  304.     mdiMain.OpenFile
  305. End Sub
  306.  
  307. Function SaveFile() As Boolean
  308.     If FileName = "Untitled.xml" Then
  309.         'if untitled then save as
  310.         SaveFile = SaveFileAs
  311.     Else
  312.         'save the file
  313.         doc.save FileName
  314.         SetFileClean
  315.         SaveFile = True
  316.     End If
  317. End Function
  318.  
  319. Private Sub mnuFileSave_Click()
  320.     SaveFile
  321. End Sub
  322.  
  323. Function SaveFileAs() As Boolean
  324. On Error GoTo CancelErr
  325.     'get a new file location
  326.     cd.Flags = cdlOFNOverwritePrompt
  327.     cd.ShowSave
  328.     FileName = cd.FileName
  329.     'save the file with new name
  330.     SaveFile
  331.     SaveFileAs = True
  332. CancelErr:
  333. End Function
  334.  
  335. Private Sub mnuFileSaveAs_Click()
  336.     SaveFileAs
  337. End Sub
  338.  
  339. Private Sub mnuHelpAbout_Click()
  340.     frmAbout.Show vbModal
  341. End Sub
  342.  
  343. 'Add new child node to the selected node
  344. Private Sub mnuNodeAdd_Click()
  345. Dim newNode As IXMLDOMNode, iNode As IXMLDOMNode
  346. Dim tvNode As node, nNode As node
  347. Dim nName As String
  348.  
  349.     On Error Resume Next
  350.     Set tvNode = tvXML.SelectedItem
  351.     Set iNode = doc.selectSingleNode(tvNode.FullPath) 'nodesCol(tvNode.Tag) 'the selected xmlnode
  352.  
  353. GetName:
  354.     nName = InputBox$("Enter Valid name for new Node", , nName)
  355.     If nName = "" Then Exit Sub 'user may have clicked cancel
  356.     nName = Replace(nName, " ", "_") 'replace space with _ character
  357.     
  358.     Set newNode = doc.createElement(nName)
  359.     If newNode Is Nothing Then 'This will trap an invalid name for new element
  360.         MsgBox Err.Description
  361.         GoTo GetName
  362.     End If
  363.     On Error GoTo 0
  364.  
  365.     'now add new node to XMLDOM, TreeView and NodesCollection
  366.     If iNode Is Nothing Then 'root element
  367.         doc.appendChild newNode
  368.     Else
  369.         iNode.appendChild newNode
  370.     End If
  371.     If tvNode Is Nothing Then
  372.         Set nNode = tvXML.Nodes.Add(, , , nName, , "selected")
  373.     Else
  374.         Set nNode = tvXML.Nodes.Add(tvNode, tvwChild, , nName, , "selected")
  375.     End If
  376.     
  377.     nNode.Image = "closed"
  378.     nNode.ExpandedImage = "open"
  379.  
  380.     'select and click the newly created node
  381.     nNode.Selected = True
  382.     tvXML_NodeClick nNode
  383.  
  384.     txtXML.Locked = False 'the text in selected node can now be edited
  385.     SetFileDirty
  386. End Sub
  387.  
  388. 'delete the selected node
  389. Private Sub mnuNodeDelete_Click()
  390. Dim tvNode As node
  391. Dim iNode As IXMLDOMNode
  392.  
  393.     Set tvNode = tvXML.SelectedItem
  394.     If tvNode Is Nothing Then Exit Sub 'routine check
  395.     
  396.     'Exit if unintentional
  397.     If MsgBox("Are u sure u want to delete '" & tvNode.Text & "' and all its sub Nodes?", vbYesNo) = vbNo Then Exit Sub
  398.     
  399.     'get xml node from nodes collection
  400.     Set iNode = doc.selectSingleNode(tvNode.FullPath)
  401.     'detach it from its parent
  402.     iNode.parentNode.removeChild iNode
  403.     'dont remove the xml node from nedescol or all indexes will fail (tvNode.Tag)
  404.     'x (nodescol.Remove tvNode.Tag)
  405.     '
  406.     'remove it from the tree view
  407.     tvXML.Nodes.Remove tvNode.Index
  408.     'pseudo click on the newly selected node
  409.     Set tvNode = tvXML.SelectedItem
  410.     If tvNode Is Nothing Then 'if the root node was deleted
  411.         txtXML.Locked = True 'no selected node so text not editable
  412.         txtXML.Text = ""
  413.     Else
  414.         tvXML_NodeClick tvNode
  415.     End If
  416.     SetFileDirty
  417. End Sub
  418.  
  419. 'the usual MDI stuff
  420. Private Sub mnuTileHori_Click()
  421.     mdiMain.Arrange vbTileHorizontal
  422. End Sub
  423.  
  424. Private Sub mnuTileVert_Click()
  425.     mdiMain.Arrange vbTileVertical
  426. End Sub
  427.  
  428. Private Sub mnuToolsFont_Click()
  429.     On Error GoTo ErrCheck
  430.     With txtXML.Font
  431.         cd.FontName = .Name
  432.         cd.FontSize = .Size
  433.         cd.FontBold = .Bold
  434.         cd.FontItalic = .Italic
  435.         cd.FontStrikethru = .Strikethrough
  436.         cd.FontUnderline = .Underline
  437.         cd.Flags = cdlCFScreenFonts
  438.         cd.ShowFont
  439.         .Name = cd.FontName
  440.         .Size = cd.FontSize
  441.         .Bold = cd.FontBold
  442.         .Italic = cd.FontItalic
  443.         .Strikethrough = cd.FontStrikethru
  444.         .Underline = cd.FontUnderline
  445.     End With
  446. ErrCheck:
  447. End Sub
  448.  
  449. Private Sub mnuWIcons_Click()
  450.     mdiMain.Arrange vbArrangeIcons
  451. End Sub
  452.  
  453. Private Sub mnuWindowCascade_Click()
  454.     mdiMain.Arrange vbCascade
  455. End Sub
  456.  
  457. Private Sub tvXML_AfterLabelEdit(Cancel As Integer, NewString As String)
  458. Dim nXMLNode As IXMLDOMNode, oXMLNode As IXMLDOMNode
  459. Dim oNode As node
  460. Dim xmlNode As IXMLDOMNode
  461.  
  462.     'Create a xmlnode element with the new name
  463.     On Error Resume Next
  464.     NewString = Replace(NewString, " ", "_") 'replace space with _ character
  465.     Set nXMLNode = doc.createElement(NewString)
  466.     If nXMLNode Is Nothing Then
  467.         MsgBox Err.Description
  468.         Cancel = True
  469.         Exit Sub
  470.     End If
  471.     On Error GoTo 0
  472.     'copy the original node's attributes and child nodes
  473.     Set oNode = tvXML.SelectedItem
  474.     Set oXMLNode = doc.selectSingleNode(oNode.FullPath)
  475.     For Each xmlNode In oXMLNode.Attributes
  476.         'item have to be removed first before inserting them in new node
  477.         oXMLNode.Attributes.removeNamedItem xmlNode.nodeName
  478.         nXMLNode.Attributes.setNamedItem xmlNode
  479.     Next
  480.     For Each xmlNode In oXMLNode.childNodes
  481.         nXMLNode.appendChild xmlNode
  482.     Next
  483.     'replace the new node with the orig node
  484.     oXMLNode.parentNode.replaceChild nXMLNode, oXMLNode
  485.     
  486.     SetFileDirty
  487. End Sub
  488.  
  489. Private Sub tvXML_DragDrop(Source As Control, x As Single, y As Single)
  490. Dim iNode As IXMLDOMNode 'selected node
  491. Dim iNodeT As IXMLDOMNode 'dropped to node
  492. Dim pNode As IXMLDOMNode 'selected node's parent
  493.  
  494.    'On Error GoTo ErrCheck
  495.    If tvXML.DropHighlight Is Nothing Then
  496.       inDrag = False
  497.       Exit Sub
  498.    Else
  499.       If xNode = tvXML.DropHighlight Then Exit Sub
  500.       'Debug.Print xNode.Text & " dropped on " & tvXML.DropHighlight.Text
  501.       'now move the node
  502.       
  503.         'get all info from treeview before changing it
  504.         Set iNode = doc.selectSingleNode(xNode.FullPath)
  505.         Set iNodeT = doc.selectSingleNode(tvXML.DropHighlight.FullPath)
  506.         Set pNode = iNode.parentNode
  507.  
  508.         'add all treeview nodes(draggedto and its child) in new location
  509.         AddNodes doc.selectSingleNode(xNode.FullPath), tvXML.DropHighlight
  510.         'remove node from treeview
  511.         tvXML.Nodes.Remove xNode.Index
  512.         'move the node in xmldoc
  513.         iNode.parentNode.removeChild iNode
  514.         iNodeT.appendChild iNode
  515.         
  516.       inDrag = False
  517.       SetFileDirty
  518.    End If
  519.    
  520.    Exit Sub
  521. ErrCheck:
  522.     MsgBox Err.Description
  523.     pNode.appendChild iNode
  524. End Sub
  525.  
  526. Private Sub tvXML_DragOver(Source As Control, x As Single, y As Single, State As Integer)
  527.    If inDrag = True Then
  528.       ' Set DropHighlight to the mouse's coordinates.
  529.       Set tvXML.DropHighlight = tvXML.HitTest(x, y)
  530.       If Not tvXML.DropHighlight Is Nothing Then tvXML.DropHighlight.Expanded = True
  531.    End If
  532. End Sub
  533.  
  534. Private Sub tvXML_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
  535.     Set xNode = tvXML.HitTest(x, y)
  536. End Sub
  537.  
  538. Private Sub tvXML_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
  539.     If xNode Is Nothing Then Exit Sub
  540.     If Button = vbLeftButton Then ' Signal a Drag operation.
  541.         inDrag = True ' Set the flag to true.
  542.         ' Set the drag icon with the CreateDragImage method.
  543.         tvXML.DragIcon = tvXML.SelectedItem.CreateDragImage
  544.         tvXML.Drag vbBeginDrag ' Drag operation.
  545.     End If
  546. End Sub
  547.  
  548. Private Sub tvXML_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
  549.     'show the node(add/delete) popup menu
  550.     If Button = 2 Then
  551.         Me.PopupMenu mnuNode
  552.     End If
  553. End Sub
  554.  
  555. 'Show the text related to this node in the textbox
  556. Private Sub tvXML_NodeClick(ByVal node As MSComctlLib.node)
  557. Dim iNode As IXMLDOMNode
  558.  
  559.     'node is clicked: get the text node associated with the xmlnode
  560.     'show text in the text box if text node exists
  561.     Set iNode = doc.selectSingleNode(node.FullPath)
  562.     txtXML.Text = ""
  563.     'I store the text as the first child node
  564.     'the node type of text node is 3
  565.     If Not iNode.firstChild Is Nothing Then
  566.         If iNode.firstChild.nodeType = 3 Then
  567.             txtXML.Text = iNode.firstChild.nodeValue
  568.         End If
  569.     End If
  570.     txtXML.Locked = False
  571.     node.Selected = True
  572.     Set tvXML.DropHighlight = node
  573. End Sub
  574.  
  575. Private Sub txtXML_Change()
  576.     'text for the selected node has changed so it is dirty
  577.     'text will also change when textbox in not in focus
  578.     If bInFocus = True Then bDirty = True
  579. End Sub
  580.  
  581. Private Sub txtXML_GotFocus()
  582.     'starting to edit node text so...
  583.     bInFocus = True
  584.     bDirty = False
  585. End Sub
  586.  
  587. Sub SaveSelNodeText()
  588. Dim tvNode As node
  589. Dim iNode As IXMLDOMNode
  590. Dim newNode As IXMLDOMText
  591.  
  592.     'get the selected node
  593.     Set tvNode = tvXML.SelectedItem
  594.     If tvNode Is Nothing Then Exit Sub 'just be sure
  595.  
  596.     Set iNode = doc.selectSingleNode(tvNode.FullPath)
  597.     'do we have a child node associated with the element node
  598.     If iNode.firstChild Is Nothing Then
  599.         'if no then create new textnode and append
  600.         Set newNode = doc.createTextNode(txtXML.Text)
  601.         iNode.appendChild newNode
  602.     Else
  603.         'if childnode is present check if it is a text node
  604.         If iNode.firstChild.nodeType = 3 Then '3: text element
  605.             iNode.firstChild.nodeValue = txtXML.Text
  606.         Else
  607.             'if no then add a text node as the first child node
  608.             Set newNode = doc.createTextNode(txtXML.Text)
  609.             iNode.insertBefore newNode, iNode.childNodes(0)
  610.         End If
  611.     End If
  612. End Sub
  613.  
  614. Private Sub txtXML_LostFocus()
  615.     bInFocus = False
  616.     If Not bDirty Then Exit Sub
  617.     'if node was edited then save it
  618.     Call SaveSelNodeText
  619.     bDirty = False
  620.     SetFileDirty
  621. End Sub
  622.  
  623.