Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Import Contents of XML file to List box

Status
Not open for further replies.

RonQA

Technical User
Jun 24, 2007
61
0
0
US
I have searched everywhere and cannot find if it is possible to Import Contents of XML file to a List box.

The XML file i am using only has 2 lines I want imported to the listbox.

Does anyone have any ideas?

Thanks,
 
You can look at the FileSysObject()
Pretty sure you can grab the contents of an XML file and save it to a table to use in your List box.

Paul
 
Here is a piece of code I found. I adapted it to my needs and it works great.

Thanks,

You have to add the Reference "Microsoft XML"

Private Sub Command85_Click()
Dim xmldoc As MSXML2.DOMDocument
Dim xmlNode As MSXML2.IXMLDOMNode
Dim xmlNodeList As MSXML2.IXMLDOMNodeList
Dim myNode As MSXML2.IXMLDOMNode
Dim dir, folder, files
Dim PRange As String
Dim wo As String
wo = WO_Num
Set fso = CreateObject("Scripting.FileSystemObject")
dir = "O:\Order Tracking Router\OTR Data\"


Set xmldoc = New MSXML2.DOMDocument
xmldoc.async = False
xmldoc.Load (dir & wo & ".xml")

Set xmlNodeList = xmldoc.getElementsByTagName("OTR_link")

For Each xmlNode In xmlNodeList
For Each myNode In xmlNode.childNodes
If myNode.nodeType = NODE_TEXT Then
List0.AddItem (xmlNode.Text)
'MsgBox xmlNode.nodeName & "=" & xmlNode.Text
End If
Next myNode
Next xmlNode
Set xmlNodeList = xmldoc.getElementsByTagName("sow")

For Each xmlNode In xmlNodeList
For Each myNode In xmlNode.childNodes
If myNode.nodeType = NODE_TEXT Then
List0.AddItem (xmlNode.Text)

End If
Next myNode
Next xmlNode


Set xmldoc = Nothing
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top