Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Pro VB 6
|
Pro VB 6 For advanced Visual Basic coders working in version 6 (not .NET). Beginning-level questions will be redirected to other forums, including Beginning VB 6.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 9th, 2007, 10:46 AM
Friend of Wrox
 
Join Date: Mar 2005
Posts: 264
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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
 
Old May 9th, 2007, 11:03 AM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Could you specify which statement raises the error?
 
Old May 9th, 2007, 11:04 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Hi there...

You forget to load the xml in objDocCopy ;) it's nothing when you reach the if...

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
 
Old May 9th, 2007, 11:07 AM
Friend of Wrox
 
Join Date: Mar 2005
Posts: 264
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by BrianWren
 Could you specify which statement raises the error?
Thanks for your reply. It is pointing at :

If objDoc.transformNode(objDoc) <> objDocCopy.transformNode(objDocCopy) Then

My main goal is to reduce the number of listview reload. I want the list view reload ONLY when its data is diffrent then newly arrived data but it seem i have problems in my way. could you look at me code and let me know what i am doing wrong in achiving this goal.Thanks

 
Old May 9th, 2007, 11:14 AM
Friend of Wrox
 
Join Date: Mar 2005
Posts: 264
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by gbianchi
 Hi there...

You forget to load the xml in objDocCopy ;) it's nothing when you reach the if...

HTH

Gonzalo
Thanks for your reply. could you tell me what should i do to fix that problem? Initially the listview is empty but after first fill my compare should start but it seem there is problem in coding this logic. My main goal is to reload listview only when new data is arrived and that data is diffrent then listview. I be happy if help me fix this problem.Thanks
 
Old May 9th, 2007, 11:19 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Code:
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
see that you dimmed objDocCopy but you never actually load the document on it, when it reach the if statement is still nothing...

also I really don't know is this is the way to compare to XML file...


HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========





Similar Threads
Thread Thread Starter Forum Replies Last Post
Comparing elements in an XML document dlorenz XSLT 0 August 7th, 2007 05:28 PM
How to check if an xml has data set in vb6? method Pro VB 6 0 May 9th, 2007 10:44 AM
Problem with repeat data in XML to XML transformat tslag XSLT 4 June 13th, 2006 08:45 AM
Comparing data from 2 datagrids lihoong VB How-To 0 April 5th, 2005 12:41 AM
XML Data Island Display Problem marcuslim XML 8 December 7th, 2004 04:00 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.