Hi,
I added Infragistics.Win.UltraWinTree.UltraTree Control to the form. Added root nodes in the nodes properties (collection) of that control. Example: Tariff Data -> Time Band List
In the Form Load event I wrote code to form a Tree for 10 MB XMl File. Code follows and also giving sample xml file. You can make that xml file as much big just by copiing time band list in between Time Band List tag.
I want to be load 10 MB XML file within 1/2 minutes
The Code in Vb.Net:
'This is the object of XMLDocument to load XML file (DOM parser)Dim obj_TariffData_XmlDocument As New XmlDocument 'This is the object of XmlNOde to get data in between TariffData nodeDim obj_TariffData_XmlNodeTariffData As XmlNode 'This is the object of XmlNode to get all child nodes of TariffData(Root Node) 'For Example all TimeBands in the given sampe XML file. "C:\TD\TD.xml"Dim obj_TariffData_XmlNodeTariffData_SubNode As XmlNode 'This is the object of XmlNOde to get the properties of specific node 'example: properties (data) are in between <TimeBand> Tag ' <TimeBand> ' <Name>OffPeak</Name> ' </TimeBand>Dim obj_TariffData_XmlNodeTimeBand As XmlNode 'This is integer varibale to assign total number of Time Bands Dim int_TariffData_NodeCountTimeBand As Integer 'This is integer variable to initialize for loop Dim int_TariffData_LoopTimeBand As Integer 'This is the object of UltraTreeNode used to get Main root node (example Time Band List)Dim obj_TariffData_TimeBandListNode As Infragistics.Win.UltraWinTree.UltraTreeNode 'This is the object of UltraTreeNode used to create new node and add to Main root node that is (Time Band List)Dim obj_TariffData_TimeBandNewNode As Infragistics.Win.UltraWinTree.UltraTreeNode 'This is integer variable to get TariffData Child nodes count Dim int_TariffData_NodeCountTariffData As Integer 'This is integer variable to intialize for loop Dim int_TariffData_LoopTariffData As Integer 'one minute = 60 000 milliseconds 'These varibales will be used to calculate time while loading xml file. Dim intStartTime As Long Dim intEndTime As Long Dim intTimeToExecute As Long 'Starts tick intStartTime = System.Environment.TickCount 'File(Path) Dim str_TariffData_FileName As String = "C:\TD\TD.xml" 'Open XML file using XML Document object obj_TariffData_XmlDocument.Load(str_TariffData_FileName) 'To get data in between TariffData nodeobj_TariffData_XmlNodeTariffData = obj_TariffData_XmlDocument.SelectSingleNode("TariffData") 'If Data is not nothing then If Not obj_TariffData_XmlNodeTariffData Is Nothing Then
'This is the object of XMLDocument to load XML file (DOM parser)
'This is the object of XmlNOde to get data in between TariffData node
'This is the object of XmlNode to get all child nodes of TariffData(Root Node)
'For Example all TimeBands in the given sampe XML file. "C:\TD\TD.xml"
'This is the object of XmlNOde to get the properties of specific node
'example: properties (data) are in between <TimeBand> Tag
' <TimeBand>
' <Name>OffPeak</Name>
' </TimeBand>
'This is integer varibale to assign total number of Time Bands
Dim int_TariffData_NodeCountTimeBand As Integer
'This is integer variable to initialize for loop
Dim int_TariffData_LoopTimeBand As Integer
'This is the object of UltraTreeNode used to get Main root node (example Time Band List)
'This is the object of UltraTreeNode used to create new node and add to Main root node that is (Time Band List)
'This is integer variable to get TariffData Child nodes count
Dim int_TariffData_NodeCountTariffData As Integer
'This is integer variable to intialize for loop
Dim int_TariffData_LoopTariffData As Integer
'one minute = 60 000 milliseconds
'These varibales will be used to calculate time while loading xml file.
Dim intStartTime As Long
Dim intEndTime As Long
Dim intTimeToExecute As Long
'Starts tick
intStartTime = System.Environment.TickCount
'File(Path)
Dim str_TariffData_FileName As String = "C:\TD\TD.xml"
'Open XML file using XML Document object
obj_TariffData_XmlDocument.Load(str_TariffData_FileName)
'To get data in between TariffData node
'If Data is not nothing then
If Not obj_TariffData_XmlNodeTariffData Is Nothing Then
'Get number of child nodes of Tariff Data
int_TariffData_NodeCountTariffData = obj_TariffData_XmlNodeTariffData.ChildNodes.Count
'If child node are there then forming a tree using for loop and getting the data from XML For int_TariffData_LoopTariffData = 0 To int_TariffData_NodeCountTariffData - 1 'Get each child node obj_TariffData_XmlNodeTariffData_SubNode = obj_TariffData_XmlNodeTariffData.ChildNodes(int_TariffData_LoopTariffData) 'Checking if it is Time Band If obj_TariffData_XmlNodeTariffData_SubNode.Name = "TimeBandList" Then 'Get Time Bands count int_TariffData_NodeCountTimeBand = obj_TariffData_XmlNodeTariffData_SubNode.ChildNodes.Count 'If number of time bands are there then adding time band nodes into its parent node For int_TariffData_LoopTimeBand = 0 To int_TariffData_NodeCountTimeBand - 1 'Get Time Band List tag obj_TariffData_TimeBandListNode = Me.UTTariffData.Nodes(0).Nodes(0) 'Creating new node for new time band obj_TariffData_TimeBandNewNode = New Infragistics.Win.UltraWinTree.UltraTreeNode 'Adding new node(new time band node) to Time Band List node obj_TariffData_TimeBandListNode.Nodes.Add(obj_TariffData_TimeBandNewNode) 'assign the name of time band to that node - get the name value from time band properties obj_TariffData_XmlNodeTimeBand = obj_TariffData_XmlNodeTariffData_SubNode.ChildNodes(int_TariffData_LoopTimeBand) 'Assigning values If Not obj_TariffData_XmlNodeTimeBand Is Nothing Then obj_TariffData_TimeBandNewNode.Tag = obj_TariffData_XmlNodeTimeBand.SelectSingleNode("Name").InnerText.ToString.Replace("<", "<").Replace(">", ">").Replace("&", "&") obj_TariffData_TimeBandNewNode.Text = obj_TariffData_XmlNodeTimeBand.SelectSingleNode("Name").InnerText.ToString.Replace("<", "<").Replace(">", ">").Replace("&", "&") End If Next End If
'If child node are there then forming a tree using for loop and getting the data from XML
For int_TariffData_LoopTariffData = 0 To int_TariffData_NodeCountTariffData - 1
'Get each child node
obj_TariffData_XmlNodeTariffData_SubNode = obj_TariffData_XmlNodeTariffData.ChildNodes(int_TariffData_LoopTariffData)
'Checking if it is Time Band
If obj_TariffData_XmlNodeTariffData_SubNode.Name = "TimeBandList" Then
'Get Time Bands count int_TariffData_NodeCountTimeBand = obj_TariffData_XmlNodeTariffData_SubNode.ChildNodes.Count 'If number of time bands are there then adding time band nodes into its parent node For int_TariffData_LoopTimeBand = 0 To int_TariffData_NodeCountTimeBand - 1 'Get Time Band List tag obj_TariffData_TimeBandListNode = Me.UTTariffData.Nodes(0).Nodes(0) 'Creating new node for new time band obj_TariffData_TimeBandNewNode = New Infragistics.Win.UltraWinTree.UltraTreeNode 'Adding new node(new time band node) to Time Band List node obj_TariffData_TimeBandListNode.Nodes.Add(obj_TariffData_TimeBandNewNode) 'assign the name of time band to that node - get the name value from time band properties obj_TariffData_XmlNodeTimeBand = obj_TariffData_XmlNodeTariffData_SubNode.ChildNodes(int_TariffData_LoopTimeBand) 'Assigning values If Not obj_TariffData_XmlNodeTimeBand Is Nothing Then obj_TariffData_TimeBandNewNode.Tag = obj_TariffData_XmlNodeTimeBand.SelectSingleNode("Name").InnerText.ToString.Replace("<", "<").Replace(">", ">").Replace("&", "&") obj_TariffData_TimeBandNewNode.Text = obj_TariffData_XmlNodeTimeBand.SelectSingleNode("Name").InnerText.ToString.Replace("<", "<").Replace(">", ">").Replace("&", "&") End If Next End If
'Get Time Bands count
int_TariffData_NodeCountTimeBand = obj_TariffData_XmlNodeTariffData_SubNode.ChildNodes.Count
'If number of time bands are there then adding time band nodes into its parent node
For int_TariffData_LoopTimeBand = 0 To int_TariffData_NodeCountTimeBand - 1
'Get Time Band List tag
obj_TariffData_TimeBandListNode = Me.UTTariffData.Nodes(0).Nodes(0)
'Creating new node for new time band
obj_TariffData_TimeBandNewNode = New Infragistics.Win.UltraWinTree.UltraTreeNode
'Adding new node(new time band node) to Time Band List node
obj_TariffData_TimeBandListNode.Nodes.Add(obj_TariffData_TimeBandNewNode)
'assign the name of time band to that node - get the name value from time band properties
obj_TariffData_XmlNodeTimeBand = obj_TariffData_XmlNodeTariffData_SubNode.ChildNodes(int_TariffData_LoopTimeBand)
'Assigning values
If Not obj_TariffData_XmlNodeTimeBand Is Nothing Then
obj_TariffData_TimeBandNewNode.Tag = obj_TariffData_XmlNodeTimeBand.SelectSingleNode("Name").InnerText.ToString.Replace("<", "<").Replace(">", ">").Replace("&", "&")
obj_TariffData_TimeBandNewNode.Text = obj_TariffData_XmlNodeTimeBand.SelectSingleNode("Name").InnerText.ToString.Replace("<", "<").Replace(">", ">").Replace("&", "&")
End If
Next
End If 'Expanding Tree UTTariffData.ExpandAll(ExpandAllType.Always) 'Bringing Tree into Front UTTariffData.BringToFront() 'Showing Tree UTTariffData.Show() 'Ends tick intEndTime = System.Environment.TickCount 'Calaculating tickes after xml file is loaded intTimeToExecute = intEndTime - intStartTime 'Showing messageMessageBox.Show("The total execution time to load Tariff Data in milli seconds(one minute = 60 000 milliseconds): " & intTimeToExecute) 'one minute = 60 000 millisecondsDim intTimeMinutesToLoadXMl As Integer = 0 intTimeMinutesToLoadXMl = intTimeToExecute / 60000 'Shoe message in minutesMessageBox.Show("The total execution time to load Tariff Data in minutes(one minute = 60 000 milliseconds): " & intTimeMinutesToLoadXMl)
'Expanding Tree
UTTariffData.ExpandAll(ExpandAllType.Always)
'Bringing Tree into Front
UTTariffData.BringToFront()
'Showing Tree
UTTariffData.Show()
'Ends tick
intEndTime = System.Environment.TickCount
'Calaculating tickes after xml file is loaded
intTimeToExecute = intEndTime - intStartTime
'Showing message
intTimeMinutesToLoadXMl = intTimeToExecute / 60000
'Shoe message in minutes
End Sub
Sample XML file: (Copy TimeBand tag with properties as many as to form Big XML)
<TariffData>
<TimeBandList>
<TimeBand> <Name>OffPeak</Name> </TimeBand>
</TimeBand>
</TimeBandList>
</TariffData>
I'm not sure what your question is. Is this taking too long to load?
There's not much I can do with a large code snippet like this. I recommend that you create a small sample project demonstrating the problem and Submit an incident to Infragistics Developer Support so they can check it out.