i am quite new to vb and am hoping to build an application in vb6 that reads some xml content and then inserts it to a database.
i have partially written 2 classes:
the xml structure i have mirrors these classes:
the CReport class does the following
1. loads the xml file into a DOM
2. sends the document element to the following LoadXML method:
Public Sub LoadXML(node As MSXML2.IXMLDOMNode)
Set node = node.childNodes(0)
Do While Not node Is Nothing
Select Case LCase(node.NodeName)
Case Is = "reportnumber"
ReportDate = node.text ' report date is a property
Case Is = "customer"
customer.Loadxml node ' customer is an instanciated
'object of the Ccustomer ' class
Case Is = "reportdate"
ReportOrganisation = node.text ' report organisation is a property
Set node = node.nextSibling
in the customer class there would also be a loadxml method which would loop through the child elements of the customer node.
The problem this created was that when the loop in the Report class reached the "customer" element it jumps into the customer class and destroys the node object in the Report class. Accordingly when the code finishes in the customer class and jumps back to the Report class i cannot use the node object for .next sibling and therfore cannot finish the loop in the Report class.
I wondered if i actually created a DOM tree within the classes and put the nodes into this. and then put the values into these and then read them from this tree. BUT it seems like this will be replicating work.
i already have the data in a DOM so why should i create another?
So my question is:
Is there any way of maintaing the Report node object whilst i move into the Customer class object. If not can you recommend any approach to achieving the same result without excessive complexity.
things to consider are:
1. i would like to use a class structure rather than doing the whole thing in one form procedure.
2. i have already read the "XML Wrapper template; Transform XML documents into vb classes" article on MSDN http://msdn.microsoft.com/msdnmag/issues/01/01/XMLWrap/default.aspx
- this is very good but i dont think i want to create another DOM structure when i already have the data in one at the start of the Report class.
3. i have not added in the inserts to the db yet but will do this later once i have exposed the content.
thankyou very much.