Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Add/Change Root Node in XML file

Posted on 2001-07-27
4
Medium Priority
?
188 Views
Last Modified: 2008-02-01
Dave Green - How can we make the root node something other than <order><\order>. I need Order and its children to be nodes. Remember you provided the following:

Option Explicit

Dim oDOM      As DOMDocument
Dim oRoot     As IXMLDOMNode
Dim oNode     As IXMLDOMNode
Dim oNodeList As IXMLDOMNodeList

Private Sub Command1_Click()

 Set oDOM = New DOMDocument
 Dim i As Long
 Dim strName As String
 Dim strXML As String
 
 Dim dblQ As String
 dblQ = Chr(34) 'double quotes
 
 oDOM.Load "C:\One.xml"

 Set oRoot = oDOM.selectSingleNode("export_data")
 
 Set oNodeList = oRoot.selectNodes("order")
 
 MsgBox oNodeList.Length
 
 For i = 0 To oNodeList.Length - 1
   Dim oNewDOM As New DOMDocument
   Set oNode = oNodeList.Item(i)
   strXML = "<?xml version=" & dblQ & "1.0" & dblQ & "?>" & oNode.xml
   Set oNode = oNode.selectSingleNode("quote_number")
   strName = oNode.Text
   With oNewDOM
     .loadXML strXML
     .Save "C:\Temp\Order" & strName & ".xml"
   End With
 Next
 
End Sub

Private Sub Form_Unload(Cancel As Integer)
 Set oDOM = Nothing
 Set oNode = Nothing
 Set oNodeList = Nothing
End Sub


Thanks!
0
Comment
Question by:cgrexer
  • 3
4 Comments
 
LVL 8

Expert Comment

by:Dave_Greene
ID: 6327855
Just make this change

For i = 0 To oNodeList.Length - 1
  Dim oNewDOM As New DOMDocument
  Set oNode = oNodeList.Item(i)
  strXML = "<?xml version=" & dblQ & "1.0" & dblQ & "?>" & "<ROOTNODEHERE> oNode.xml
  Set oNode = oNode.selectSingleNode("quote_number")
  strName = oNode.Text & "</ROOTNODEHERE>
  With oNewDOM
    .loadXML strXML
    .Save "C:\Temp\Order" & strName & ".xml"
  End With
Next
0
 
LVL 8

Accepted Solution

by:
Dave_Greene earned 400 total points
ID: 6327898
Oops... Brain Slip...  

For i = 0 To oNodeList.Length - 1
 Dim oNewDOM As New DOMDocument
 Set oNode = oNodeList.Item(i)
 strXML = "<?xml version=" & dblQ & "1.0" & dblQ & "?>" & "<ROOTNODEHERE>" & oNode.xml & "</ROOTNODEHERE>"
 Set oNode = oNode.selectSingleNode("quote_number")
 strName = oNode.Text
 With oNewDOM
   .loadXML strXML
   .Save "C:\Temp\Order" & strName & ".xml"
 End With
Next
0
 

Author Comment

by:cgrexer
ID: 6328013
Dave -

You da' man! Thanks again and sorry for misspelling your last name.

Grant
0
 
LVL 8

Expert Comment

by:Dave_Greene
ID: 6328152
Anytime, Have a great weekend Gran

Just Kidding  :)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

824 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