Solved

How to repeat the structure of xml in visualbasic

Posted on 2001-07-25
42
181 Views
Last Modified: 2013-11-25
Hi

I have a question for you all: My question is:

I got an xml file which looks like:

<import detail>
<detail>
<time>bla bla</time>
<date>bla bla</date>
<start>bla bla</start>
</detail>
</import detail>

I'm creating the above xml file using DOM document in visualbasic using xml parser ver 3.0. for example it looks like this:

Set objparent = m_objimporter.createElement("import detail")
m_objimporter.appendChild objparent
objparent.setAttribute "template", "Default"

Set objtradeimport = m_objimporter.createElement("time")
objparent.appendChild objtradeimport
objtradeimport.setAttribute "type", B_tradetype
'
'
'
etc...

My problem is:

I want to send the detail fields again and again in the same xml file like:
<import detail>
<detail>
<time>bla bla</time>
<date>bla bla</date>
<start>bla bla</start>
</detail>
<detail>
<time>bla bla</time>
<date>bla bla</date>
<start>bla bla</start>
</detail>
<detail>
<time>bla bla</time>
<date>bla bla</date>
<start>bla bla</start>
</detail>
</import detail>

I have different time,date,start values every time i sent and i want basically to repeat the detail information again and filled with different values in the sam xml file.
How can i acheive that.

-Cheers
0
Comment
Question by:vmandem
  • 22
  • 16
  • 4
42 Comments
 
LVL 8

Expert Comment

by:Dave_Greene
ID: 6319412
If I'm reading the question correctly... here is what I would do.

Build your DOM

If oDOM Is Nothing Then
       
       Set oDOM = New DOMDocument
       '
       ' New Document, add headings
       '
       Set oNode = oDOM.createProcessingInstruction("xml", "version='1.0'")
       Set oNode = oDOM.insertBefore(oNode, oDOM.childNodes.Item(0))
       
       '
       ' Create document roots
       '
       Set oRoot = m_XML_DOM.createElement("import_detail")
       Set m_XML_DOM.documentElement = oRoot
       
       Set oChild = m_XML_DOM.createElement("Detail")
       oRoot.appendChild oChild

       Set oNode = oChild

   End If

Build your node

   Dim oAttrib     As IXMLDOMAttribute

   '
   ' set node attributes
   '
   Set oAttrib = m_XML_DOM.createAttribute("time")
   oAttrib.Text = ""  'blank value for default node
   oNode.Attributes.setNamedItem oAttrib
   
   Set oAttrib = m_XML_DOM.createAttribute("date")
   oAttrib.Text = m_Offset
   oNode.Attributes.setNamedItem oAttrib

   Set oAttrib = m_XML_DOM.createAttribute("start")
   oAttrib.Text = m_Offset
   oNode.Attributes.setNamedItem oAttrib

   Dim xNode       As IXMLDOMNode

   For i = 1 to NumberDesired
      Set xNode = oNode
     

      xNode.Attributes.getNamedItem("time").Text = sTime
      xNode.Attributes.getNamedItem("date").Text = sDate
      xNode.Attributes.getNamedItem("start").Text = sStart
     
      oRoot.appendChild xNode  
   Next

   

0
 
LVL 8

Expert Comment

by:Dave_Greene
ID: 6319419
one change


  oAttrib.Text = ""  'for all
0
 

Author Comment

by:vmandem
ID: 6319642
Dave

I'm already creating the whole structure like :

<?xml version="1.0"> etc..

And i got the whole structure of the xml file the way i explained earlier:

Do i need to check the: If condition you mentioned at the beginning.

I only want to repeat the <detail>----------</detail> tag repeated in the same structure but i'm passing different values for:time,date,start fields.


AND I can't understand at this point in ur code:

Set oAttrib = m_XML_DOM.createAttribute("time")
  oAttrib.Text = ""  'blank value for default node
  oNode.Attributes.setNamedItem oAttrib
 
  Set oAttrib = m_XML_DOM.createAttribute("date")
  oAttrib.Text = m_Offset
  oNode.Attributes.setNamedItem oAttrib


what is the blank value for default node and m_Offset.

I'm using this way to build the structure:

Dim m_objimporter As New DOMDocument

--Before this i'm creating <import detail> element.

Set objdetail = m_objimporter.createElement("Detail")
objimport.appendChild objdetail

Set objNewchild = m_objimporter.createElement("time")
objNewchild.Text = str1
objdetail.appendChild objNewchild

Set objNewchild = m_objimporter.createElement("date")
objNewchild.Text = str2
objdetail.appendChild objNewchild

Set objNewchild = m_objimporter.createElement("start")
objNewchild.Text = str3
objdetail.appendChild objNewchild

-VM
0
 
LVL 8

Expert Comment

by:Dave_Greene
ID: 6319668
The blank value, if to create a dummy node that you can easily populate with data.

If you create the template.  then appending large amounts of data will run faster and be programmatically easier.

That's whats going on here

For i = 1 to NumberDesired
     Set xNode = oNode  <--- Copy of the template, where onode was created as the template

     xNode.Attributes.getNamedItem("time").Text = sTime
     xNode.Attributes.getNamedItem("date").Text = sDate
     xNode.Attributes.getNamedItem("start").Text = sStart
     
     oRoot.appendChild xNode   <-- add the new values
  Next
0
 
LVL 8

Expert Comment

by:Dave_Greene
ID: 6319674
You really don't want to do all of that appending as your example shows. Really slow.
0
 

Author Comment

by:vmandem
ID: 6319789
Dave

I'm already creating the whole structure like :

<?xml version="1.0"> etc..

And i got the whole structure of the xml file the way i explained earlier:

Do i need to check the: If condition you mentioned at the beginning.

I only want to repeat the <detail>----------</detail> tag repeated in the same structure but i'm passing different values for:time,date,start fields.


AND I can't understand at this point in ur code:

Set oAttrib = m_XML_DOM.createAttribute("time")
  oAttrib.Text = ""  'blank value for default node
  oNode.Attributes.setNamedItem oAttrib
 
  Set oAttrib = m_XML_DOM.createAttribute("date")
  oAttrib.Text = m_Offset
  oNode.Attributes.setNamedItem oAttrib


what is the blank value for default node and m_Offset.

I'm using this way to build the structure:

Dim m_objimporter As New DOMDocument

--Before this i'm creating <import detail> element.

Set objdetail = m_objimporter.createElement("Detail")
objimport.appendChild objdetail

Set objNewchild = m_objimporter.createElement("time")
objNewchild.Text = str1
objdetail.appendChild objNewchild

Set objNewchild = m_objimporter.createElement("date")
objNewchild.Text = str2
objdetail.appendChild objNewchild

Set objNewchild = m_objimporter.createElement("start")
objNewchild.Text = str3
objdetail.appendChild objNewchild

-VM
0
 

Author Comment

by:vmandem
ID: 6319923
Dave

I'm getting an error at the : xNode.Attributes.(at arrow shown)

For i = 1 To 20
Set xNode = objTradedetail

-->xNode.Attributes.getNamedItem("times").Text = str1

error: Object variable or with block variable not set.

what could be the problem.
0
 
LVL 8

Expert Comment

by:Dave_Greene
ID: 6319941
Sorry, typo  

xNode.Attributes.getNamedItem("time").Text = str1
 
Remove the extra "s" in time(s)
0
 

Author Comment

by:vmandem
ID: 6320003
dave still it is giving the same error. What it could be.

Thanks
Vmandem
0
 
LVL 8

Expert Comment

by:Dave_Greene
ID: 6320011
V,

Could you post your whole routine, it could be many different things now.

Thanks
-D
0
 

Author Comment

by:vmandem
ID: 6320058
sure here you go:

dim m_objimporter as new domdocument
Dim objparent As IXMLDOMElement
Dim objNewchild As IXMLDOMElement
Dim objdetail As IXMLDOMElement
Dim objtradeimport As IXMLDOMElement
Dim xNode As IXMLDOMNode

Set objparent = m_objimporter.createElement("importFile")
m_objimporter.appendChild objparent
objparent.setAttribute "template", "Default"

Set objtradeimport = m_objimporter.createElement("tradeImport")
objparent.appendChild objtradeimport
objtradeimport.setAttribute "type", B_tradetype

Set objNewchild = m_objimporter.createElement("audit")
objNewchild.Text = "NEW"
objtradeimport.appendChild objNewchild


 Set objTradedetail = m_objimporter.createElement("Detail")
 objtradeimport.appendChild objTradedetail

Set objNewchild = m_objimporter.createElement("times")
objNewchild.Text = B_starttime
objTradedetail.appendChild objNewchild

Set objNewchild = m_objimporter.createElement("timee")
objNewchild.Text = B_stoptime
objTradedetail.appendChild objNewchild

Set objNewchild = m_objimporter.createElement("dates")
objNewchild.Text = Newdeliveryperiod
objTradedetail.appendChild objNewchild

Set objNewchild = m_objimporter.createElement("datee")
objNewchild.Text = Newtoperiod
objTradedetail.appendChild objNewchild

Here i'm doing your stuff:

For i = 1 To 20
Set xNode = objTradedetail
xNode.Attributes.getNamedItem("times").Text = B_starttime
xNode.Attributes.getNamedItem("timee").Text = B_stoptime
xNode.Attributes.getNamedItem("dates").Text = Newdeliveryperiod
xNode.Attributes.getNamedItem("datee").Text = Newtoperiod
xNode.Attributes.getNamedItem("price").Text = B_price
xNode.Attributes.getNamedItem("days").Text = B_tradecalendar

objTradedetail.appendChild xNode
Next i

0
 
LVL 3

Expert Comment

by:Hornet241
ID: 6320143
Hi vmandem, try this

NOTE - I moved your Append to inside the for loop to add the nodes as required

For i = 1 To 20
    objtradeimport.appendChild objTradedetail
    Set xNode = objtradeimport.GetElementByTagname("Detail").Item(i - 1)
    xNode.GetElementByTagname("times").Item(0).Text = B_starttime
    xNode.GetElementByTagname("timee").Item(0).Text = B_stoptime
    xNode.GetElementByTagname("dates").Item(0).Text = Newdeliveryperiod
    xNode.GetElementByTagname("datee").Item(0).Text = Newtoperiod
    xNode.GetElementByTagname("price").Item(0).Text = B_price
    xNode.GetElementByTagname("days").Item(0).Text = B_tradecalendar

Next i

0
 
LVL 8

Expert Comment

by:Dave_Greene
ID: 6320189
I see your problem, you created elements instead of attributes.  Element lists are slower than attributes of a node in DOM so I suggest you create the attributes instead of the elements...  here is my code again

<<
  Dim oAttrib     As IXMLDOMAttribute

  '
  ' set node attributes
  '
  Set oAttrib = m_XML_DOM.createAttribute("time")
  oAttrib.Text = ""  'blank value for default node
  oNode.Attributes.setNamedItem oAttrib
 
  Set oAttrib = m_XML_DOM.createAttribute("date")
  oAttrib.Text = m_Offset
  oNode.Attributes.setNamedItem oAttrib

  Set oAttrib = m_XML_DOM.createAttribute("start")
  oAttrib.Text = m_Offset
  oNode.Attributes.setNamedItem oAttrib
>>
0
 

Author Comment

by:vmandem
ID: 6322181
Dave the problem is i have to change a lot of code that will impact me more and will take more time, the code i posted is very small but there is lot of code involved in this, that is why i want to follow the element method. could you please tell me a method to do that.

comment for Hornett:

Hornet i tried your method but when i say xNode.    i can't see Getelementbytagname option what could be the reason.

I declared xNode as ixmldomelement in your case.
but when i say objtradeimport.   i can see the getelementbytagname option.

0
 
LVL 8

Expert Comment

by:Dave_Greene
ID: 6322197
Ok, We'll modify it the element way.  One sec
0
 

Author Comment

by:vmandem
ID: 6322324
Dave the problem is i have to change a lot of code that will impact me more and will take more time, the code i posted is very small but there is lot of code involved in this, that is why i want to follow the element method. could you please tell me a method to do that.

comment for Hornett:

Hornet i tried your method but when i say xNode.    i can't see Getelementbytagname option what could be the reason.

I declared xNode as ixmldomelement in your case.
but when i say objtradeimport.   i can see the getelementbytagname option.

0
 

Author Comment

by:vmandem
ID: 6322402
Dave the problem is i have to change a lot of code that will impact me more and will take more time, the code i posted is very small but there is lot of code involved in this, that is why i want to follow the element method. could you please tell me a method to do that.

comment for Hornett:

Hornet i tried your method but when i say xNode.    i can't see Getelementbytagname option what could be the reason.

I declared xNode as ixmldomelement in your case.
but when i say objtradeimport.   i can see the getelementbytagname option.

0
 

Author Comment

by:vmandem
ID: 6322453
Dave the problem is i have to change a lot of code that will impact me more and will take more time, the code i posted is very small but there is lot of code involved in this, that is why i want to follow the element method. could you please tell me a method to do that.

comment for Hornett:

Hornet i tried your method but when i say xNode.    i can't see Getelementbytagname option what could be the reason.

I declared xNode as ixmldomelement in your case.
but when i say objtradeimport.   i can see the getelementbytagname option.

0
 
LVL 8

Expert Comment

by:Dave_Greene
ID: 6322489
Here is what I would do

dim m_objimporter as new domdocument
Dim objparent As IXMLDOMElement
Dim objNewchild As IXMLDOMElement
Dim objdetail As IXMLDOMElement
Dim objtradeimport As IXMLDOMElement

Set objparent = m_objimporter.createElement("importFile")
m_objimporter.appendChild objparent
objparent.setAttribute "template", "Default"

Set objtradeimport = m_objimporter.createElement("tradeImport")
objparent.appendChild objtradeimport
objtradeimport.setAttribute "type", B_tradetype

Set objNewchild = m_objimporter.createElement("audit")
objNewchild.Text = "NEW"
objtradeimport.appendChild objNewchild


Set objTradedetail = m_objimporter.createElement("Detail")
objtradeimport.appendChild objTradedetail

'call the new sub here
For i = 1 To 20
   LoadNodes(Start(i), Stop(i), Delivery(i), Period(i)
Next i

'Create a sub to perform the child loads

Private Sub LoadNodes(B_starttime as string, B_stoptime as string, Newdeliveryperiod as string, Newtoperiod as string)

   Set objNewchild = m_objimporter.createElement("times")
   objNewchild.Text = B_starttime
   objTradedetail.appendChild objNewchild

   Set objNewchild = m_objimporter.createElement("timee")
   objNewchild.Text = B_stoptime
   objTradedetail.appendChild objNewchild

   Set objNewchild = m_objimporter.createElement("dates")
   objNewchild.Text = Newdeliveryperiod
   objTradedetail.appendChild objNewchild

   Set objNewchild = m_objimporter.createElement("datee")
   objNewchild.Text = Newtoperiod
   objTradedetail.appendChild objNewchild

End Sub
0
 

Author Comment

by:vmandem
ID: 6322686
Dave it is giving me error:

expected expression at this line:

LoadNodes(Start(i),stop(i),Delivery(i),Period(i))

-->AT: stop(i)

the whole line appears in Red
0
 

Author Comment

by:vmandem
ID: 6322709
Dave it is giving me error:

expected expression at this line:

LoadNodes(Start(i),stop(i),Delivery(i),Period(i))

-->AT: stop(i)

the whole line appears in Red
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 8

Expert Comment

by:Dave_Greene
ID: 6322714
These are the values you want to put into the nodes

I have suggested the use of string arrays... but didn't code to it.

Use this for testing purposes

Dim Start(20) as string
Dim Stop(20) as string
Dim Delivery(20) as string
Dim Period(20) as string

For i = 1 to 20
  Start(i) = "Start" & i
  Stop(i) = "Stop" & i
  Delivery(i) = "Delivery" & i
  Period(i) = "Period" & i
Next

'call the new sub here
For i = 1 To 20
  LoadNodes(Start(i), Stop(i), Delivery(i), Period(i)
Next i
0
 

Author Comment

by:vmandem
ID: 6322811
Still i find error at LoadNodes(start(i).....)

Error is: compile error, expected =

and the whole statement is in red.

Earlier i got error with stop(i) because stop is a keyword in visualbasic but now i'm getting the above error.

It is expecting something at the end of LoadNodes(start(i),...)=

 
0
 
LVL 8

Expert Comment

by:Dave_Greene
ID: 6322818
Sorry!

Call LoadNodes(Start(i), Stop(i), Delivery(i), Period(i))
0
 

Author Comment

by:vmandem
ID: 6323731
Dave

Now i found different error.

In the procedure i'm getting:

object variable or with block variable not set.

Dim m_objimporter As New DOMDocument
 Dim objparent As IXMLDOMElement
 Dim objNewchild As IXMLDOMElement
 Dim objdetail As IXMLDOMElement
 Dim objtradeimport As IXMLDOMElement
 Dim objTradedetail As IXMLDOMElement
 
  Set objNewchild = m_objimporter.createElement("times")
-->objNewchild.Text = B_starttime
  objTradedetail.appendChild objNewchild

  Set objNewchild = m_objimporter.createElement("timee")
  objNewchild.Text = B_stoptime
  objTradedetail.appendChild objNewchild

  Set objNewchild = m_objimporter.createElement("dates")
  objNewchild.Text = Newdeliveryperiod
  objTradedetail.appendChild objNewchild

  Set objNewchild = m_objimporter.createElement("datee")
  objNewchild.Text = Newtoperiod
  objTradedetail.appendChild objNewchild

End Sub


It is showing error at the arrow i mentioned above.
I thought i didn't declared variables, so i declared the variables at the beginning of procedure, still it gives me the above error. what could be the problem.

Thanks
0
 
LVL 8

Expert Comment

by:Dave_Greene
ID: 6323900
It's because this statement didn't create the node

m_objimporter.createElement("times")


Make sure m_objimporter is in scope
0
 

Author Comment

by:vmandem
ID: 6323964
I think it is with in the scope:m_objimporter

Because i'm able to create the same nodes outside of procedure first time but when i call this procedure it is failing.

The procedure typically looks like the one you created earlier.

Now i made a small addition at the beginning adding:

 Set objTradedetail = m_objimporter.createElement("tradeDetail")
  objtradeimport.appendChild objTradedetail
 
because i want the file looks like:

<import detail>
<tradeDetail>
<times>bla bla</times>
<dates>bla bla</dates>
<timee>bla bla</timee>
</detail>
<detail>
<time>bla bla</time>
<date>bla bla</date>
<start>bla bla</start>
</detail>
</import detail>
 
But still giving the same error at the beginning :
set objTradedetail= ..

'THE PROCEDURE STARTS:

Private Sub LoadNodes(B_starttime As String, B_stoptime As String, Newdeliveryperiod As String, Newtoperiod As String)

 Dim m_objimporter As New DOMDocument
 Dim objparent As IXMLDOMElement
 Dim objNewchild As IXMLDOMElement
 Dim objdetail As IXMLDOMElement
 Dim objtradeimport As IXMLDOMElement
 Dim objTradedetail As IXMLDOMElement
 
  Set objTradedetail = m_objimporter.createElement("tradeDetail")
  objtradeimport.appendChild objTradedetail
 
  Set objNewchild = m_objimporter.createElement("times")
  objNewchild.Text = B_starttime
  objTradedetail.appendChild objNewchild

  Set objNewchild = m_objimporter.createElement("timee")
  objNewchild.Text = B_stoptime
  objTradedetail.appendChild objNewchild

  Set objNewchild = m_objimporter.createElement("dates")
  objNewchild.Text = Newdeliveryperiod
  objTradedetail.appendChild objNewchild

  Set objNewchild = m_objimporter.createElement("datee")
  objNewchild.Text = Newtoperiod
  objTradedetail.appendChild objNewchild

End Sub
0
 

Author Comment

by:vmandem
ID: 6323969
sorry the xml file must look like:

<import detail>
<tradeDetail>
<times>bla bla</times>
<dates>bla bla</dates>
<timee>bla bla</timee>
</tradeDetail>
<tradeDetail>
<time>bla bla</time>
<date>bla bla</date>
<start>bla bla</start>
</tradeDetail>
</import detail>
0
 
LVL 8

Expert Comment

by:Dave_Greene
ID: 6324027
Make the DOM locally global.  Move the DIM statement to the top of the form.

Option Explicit

Dim m_objimporter As New DOMDocument



0
 

Author Comment

by:vmandem
ID: 6324087
Now it is asking for :

Object required.

Error Number:424

I moved as you said.

Failing at:
-->Set objTradedetail = m_objimporter.createElement("tradeDetail")
0
 
LVL 8

Expert Comment

by:Dave_Greene
ID: 6324161
Then what else could it be???  Missing object...

Dim objTradedetail As IXMLDOMElement
0
 

Author Comment

by:vmandem
ID: 6324260
If i tried removing option explicit and tried declaring the variables in the procedure it is showing:

Object variable or with block variable not set

Else

it is giving:
Object required

I'm just wondering what it could be, i tested all the ways still it is showing the above errors.
0
 
LVL 8

Expert Comment

by:Dave_Greene
ID: 6324282
Can't help you on this one, make sure everything is typed in correctly... good luck
0
 

Author Comment

by:vmandem
ID: 6324391
Ok thankyou Dave for your help. I will try and i will let you know.

Thanks
VM
0
 
LVL 8

Expert Comment

by:Dave_Greene
ID: 6324431
Keep me posted...  It could be that the object being created from the createelement statement is causing the problem

check it like so

If isnothing(objTradedetail) then msgbox "It didn't get applied"
0
 

Author Comment

by:vmandem
ID: 6324781
I will, still testing but finding the same problem. I don't no why it is giving that. I will definetly post you.

Thanks
VM
0
 
LVL 3

Expert Comment

by:Hornet241
ID: 6325455
Hi sorry I was away,

If you don't declare any of the elements or nodes, or you declare them just as Objects you should have no problem

Note where I use the .Item(i-1) and the .Item(0)
0
 
LVL 3

Expert Comment

by:Hornet241
ID: 6325770
Hi I've done alot of checking and I found that when you use the .appendchild method to a node it completely associates the variable appended to the node so if you try to append the variable again you get no error but you still have only one child node

you can look at this by checking the .xml property of your objTradedetail element as you change the text values of the append child node.

Also I typo'd on the method  
     
     GetElementByTagName
It Should be
     GetElementsByTagName

Later
0
 

Author Comment

by:vmandem
ID: 6327192
Hornet

I'm getting an error at the second line of the code:

Error is: Object variable or with block variable not set.


Dim xNode As IXMLDOMElement
For i = 1 To 2
   objtradeimport.appendChild objTradedetail
   Set xNode = objtradeimport.getElementsByTagName("Detail").Item(i - 1)
--> xNode.getElementsByTagName("times").Item(0).Text = B_starttime
   xNode.getElementsByTagName("timee").Item(0).Text = B_stoptime
   xNode.getElementsByTagName("dates").Item(0).Text = Newdeliveryperiod
   xNode.getElementsByTagName("datee").Item(0).Text = Newtoperiod
   xNode.getElementsByTagName("price").Item(0).Text = B_price
   xNode.getElementsByTagName("days").Item(0).Text = B_tradecalendar

Next i

It comes up at the arrow shown above. and when i put my mouse cursor at the set xNode it shows Nothing.

0
 

Author Comment

by:vmandem
ID: 6327377
Hornet

First time the loop goes fine but when it comes second time into the loop, it is failing showing:
object variable or with block variable not set at the arrow shown in the previous comment.
what could be the problem. when i go and see the xml file
the structure <detail>...</detail> apperas only once and it is not repeated.

0
 
LVL 3

Accepted Solution

by:
Hornet241 earned 50 total points
ID: 6327383
This code works


Dim m_objimporter As New domdocument

Set objparent = m_objimporter.createElement("importFile")
m_objimporter.appendChild objparent
objparent.setAttribute "template", "Default"

Set objtradeimport = m_objimporter.createElement("tradeImport")
objparent.appendChild objtradeimport
objtradeimport.setAttribute "type", B_tradetype

Set objNewchild = m_objimporter.createElement("audit")
objNewchild.Text = "NEW"
objtradeimport.appendChild objNewchild


Set objTradedetail = m_objimporter.createElement("Detail")

Set objNewchild = m_objimporter.createElement("times")
objTradedetail.appendChild objNewchild

Set objNewchild = m_objimporter.createElement("timee")
objTradedetail.appendChild objNewchild

Set objNewchild = m_objimporter.createElement("dates")
objTradedetail.appendChild objNewchild

Set objNewchild = m_objimporter.createElement("datee")
objTradedetail.appendChild objNewchild

Set objNewchild = m_objimporter.createElement("price")
objTradedetail.appendChild objNewchild

Set objNewchild = m_objimporter.createElement("days")
objTradedetail.appendChild objNewchild


For i = 1 To 20
objtradeimport.appendChild objTradedetail
Set xNode = objtradeimport.getElementsByTagName("Detail").Item(i - 1)
xNode.getElementsByTagName("times").Item(0).Text = B_starttime
xNode.getElementsByTagName("timee").Item(0).Text = B_stoptime
xNode.getElementsByTagName("dates").Item(0).Text = Newdeliveryperiod
xNode.getElementsByTagName("datee").Item(0).Text = Newtoperiod
xNode.getElementsByTagName("price").Item(0).Text = B_price
xNode.getElementsByTagName("days").Item(0).Text = B_tradecalendar

Set MyNewNode = xNode.cloneNode(True)
Set objTradedetail = MyNewNode

Next i

0
 

Author Comment

by:vmandem
ID: 6327584
Hornett

The code works and thankyou for your constant support.

-VM

Comment to Dave:

Dave

I will definetly try your method and i'm very thankfull for your support too.

I really enjoy the knowledge transfer from you guys.

Once again thankyou all.

VM
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now