Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
415
Performance issue while forming a tree for 10 MB XML file using Infragistics Controls
posted

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:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

'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 node

Dim 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 node

obj_TariffData_XmlNodeTariffData = obj_TariffData_XmlDocument.SelectSingleNode("TariffData")

'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("&lt;", "<").Replace("&gt;", ">").Replace("&amp;", "&")

obj_TariffData_TimeBandNewNode.Text = obj_TariffData_XmlNodeTimeBand.SelectSingleNode("Name").InnerText.ToString.Replace("&lt;", "<").Replace("&gt;", ">").Replace("&amp;", "&")

End If

Next

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 message

MessageBox.Show("The total execution time to load Tariff Data in milli seconds(one minute = 60 000 milliseconds): " & intTimeToExecute)

'one minute = 60 000 milliseconds

Dim intTimeMinutesToLoadXMl As Integer = 0

intTimeMinutesToLoadXMl = intTimeToExecute / 60000

'Shoe message in minutes

MessageBox.Show("The total execution time to load Tariff Data in minutes(one minute = 60 000 milliseconds): " & intTimeMinutesToLoadXMl)

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>

Parents
No Data
Reply Children
No Data