Results 1 to 1 of 1
  1. #1
    Join Date
    Apr 2005
    Posts
    203

    Unanswered: Problem comparing xml data vb6

    I am trying to compare 2 xml files but i keep getting the following error. could any one tell me what i am dong wrong here.Thanks

    error:
    Code:
    Run-time error  91:
    
    Object variable or with lock variable not set
    pointing at:

    Code:
    If objDoc.transformNode(objDoc) <> objDocCopy.transformNode(objDocCopy) Then
    Code:
    Private Sub Form_Load()
    
    
        'Set up the listview
        ListView1.View = lvwReport
        ListView1.ColumnHeaders.Add , , "Artist"
        ListView1.ColumnHeaders.Add , , "Name"
        ListView1.ColumnHeaders.Add , , "Image"
        ListView1.ColumnHeaders.Add , , "Rating"
        ListView1.ColumnHeaders.Add , , "Song ID"
        ListView1.ColumnHeaders.Add , , "Total Votes"
        ListView1.ColumnHeaders.Add , , "Page"
        ListView1.ColumnHeaders.Add , , "Referrer"
        ListView1.ColumnHeaders.Add , , "pageWindowName"
        XMLCompair
       
        'Timer1.Interval = 60000 ' <-- one minute
        Timer1.Interval = 7000 ' <-- 10 seconds
        Timer1.Enabled = True
        
       
    End Sub
    
    
    Private Sub XMLCompair()
      Dim objDoc As MSXML2.DOMDocument
    Dim objDocCopy As MSXML2.DOMDocument
    
      'load the xml document
      Set objDoc = New MSXML2.DOMDocument
      objDoc.async = False
      objDoc.Load "http://localhost/data.php"
    
    
    
    If objDoc.transformNode(objDoc) <> objDocCopy.transformNode(objDocCopy) Then
         Set objDocCopy = objDoc
         PopulateListview
    End If
    End Sub
    
    Private Sub PopulateListview()
    Dim objDoc As MSXML2.DOMDocument
    Dim objNodelist As IXMLDOMNodeList
    Dim objNode As IXMLDOMNode
    Dim lvwItem As ListItem
    
        'load the xml document
        Set objDoc = New MSXML2.DOMDocument
        objDoc.async = False
        objDoc.Load "http://localhost/data.php"
        
        'add all the song nodes into a  nodelist
        Set objNodelist = objDoc.selectNodes("//song")
        
        'Clear the listview
        ListView1.ListItems.Clear
    
        'Loop through each song node and add to the list view
        For Each objNode In objNodelist
            Set lvwItem = ListView1.ListItems.Add(, , objNode.selectSingleNode("artist").Text)
            lvwItem.SubItems(1) = objNode.selectSingleNode("name").Text
            lvwItem.SubItems(2) = objNode.selectSingleNode("image").Text
            lvwItem.SubItems(3) = objNode.selectSingleNode("rating").Text
            lvwItem.SubItems(4) = objNode.selectSingleNode("songid").Text
            lvwItem.SubItems(5) = objNode.selectSingleNode("totalvotes").Text
            lvwItem.SubItems(6) = objNode.selectSingleNode("page").Text
            lvwItem.SubItems(7) = objNode.selectSingleNode("referrer").Text
            lvwItem.SubItems(8) = objNode.selectSingleNode("pageWindowName").Text
        Next objNode
    
        Set lvwItem = Nothing
        Set objNodelist = Nothing
       Set objDoc = Nothing
    End Sub
    Last edited by mehran; 05-09-07 at 13:23.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •