LOTUSSCRIPT/COM/OLE CLASSES
Sub getPersonDocs (node As NotesDOMElementNode) 'node is the root element of the xml file Dim documentList As NotesDOMNodeList Dim nDocument As Integer 'number of <document> elements Dim i As Integer 'counter for documentList Dim child As NotesDOMNode Dim eNode As NotesDOMElementNode Dim n As Integer 'number of attributes If node.IsNull Then Exit Sub Set documentList = node.GetElementsByTagName ("document") nDocument = documentList.NumberOfEntries If nDocument = 0 Then Exit Sub 'no document elements in file REM Check the child nodes of the root element Set child = node.FirstChild For i = 1 To nDocument While Not child.NodeName = "document" Set child = child.NextSibling Wend REM We found an element node named "document" If child.Attributes.NumberOfEntries > 0 Then REM The node has attritubes Set eNode = child 'switch to element node For n = 1 To eNode.Attributes.NumberOfEntries If eNode.GetAttribute("form") = "Person" Then REM The node has the right attribute name and value Call getData (eNode) End If Next End If REM Look for another Person document Set child = child.NextSibling Next End Sub
Sub getData (node As Notesdomelementnode) 'node is an element named "document" Dim itemList As NotesDOMNodeList Dim nItem As Integer 'number of <item> elements Dim i As Integer 'counter for itemList Dim child As NotesDOMNode Dim eNode As Notesdomelementnode Dim n As Integer 'number of attributes If node.IsNull Then Exit Sub Set itemList = node.GetElementsByTagName ("item") nItem = itemList.NumberOfEntries If nItem = 0 Then Exit Sub 'no item elements in node REM Check the child nodes of this element Set child = node.FirstChild For i = 1 To nItem While Not child.NodeName = "item" Set child = child.NextSibling Wend REM We found an element node named "item" If child.Attributes.NumberOfEntries > 0 Then REM The node has attritubes Set eNode = child 'switch to element node For n = 1 To eNode.Attributes.NumberOfEntries REM Look for an attribute named "name" REM Only one of the following matches will be found for this node If eNode.GetAttribute("name") = "FirstName" Then REM We found a matching attribute value domParser.Output (NL) Call writeData (eNode) n = eNode.Attributes.NumberOfEntries 'done with this node End If If eNode.GetAttribute("name") = "LastName" Then REM We found a matching attribute value domParser.Output (" ") Call writeData (eNode) domParser.Output (NL) n = eNode.Attributes.NumberOfEntries 'done with this node End If If eNode.GetAttribute("name") = "OfficePhoneNumber" Then REM We found a matching attribute value domParser.Output (" ") Call writeData (eNode) domParser.Output (NL) n = eNode.Attributes.NumberOfEntries 'done with this node End If Next 'continue searching for a matching attribute End If REM Look for another matching item Set child = child.Nextsibling Next End Sub
See Also