I have the below code. It works fine, but it takes too long to load, well about 30 seconds. Is there anything I can do to shorten this time.
Also, I would like to search the xml file for documents with NAME starting with A,B,C etx. How do I do that?
Many thanks,
Dim xdoc As New XPathDocument(xt)
Dim nav As XPathNavigator = xdoc.CreateNavigator()
Dim expr As XPathExpression
expr = nav.Compile("/pf:CONTRACTS/pf:CONTRACT")
Dim namespaceManager As XmlNamespaceManager = New XmlNamespaceManager(nav.NameTable)
namespaceManager.AddNamespace("pf", "http://namespace/")
expr.SetContext(namespaceManager)
Dim nodes As XPathNodeIterator = nav.Select(expr)
If nodes.Count <> 0 Then
Dim tr As String = Nothing
For Each node As XPathNavigator In nodes
tr += "<td><a Target='_blank' href='http://www.urltosite.aspx?contract=" & node.SelectSingleNode("pf:ID", namespaceManager).Value & "'>" & node.SelectSingleNode("pf:NAME", namespaceManager).Value & "</a></td>"
For Each subNode2 As XPathNavigator In node.Select("pf:SUPPLIERS/pf:SUPPLIER", namespaceManager)
tr += "<td>" & subNode2.SelectSingleNode("pf:SUPPLIERNAME", namespaceManager).Value & "</td>"
Next
tr += "<td>" & node.SelectSingleNode("pf:ENDDATE", namespaceManager).Value & "</td>"
tr += "</tr>"
Next
Dim th As String = "<th width='50%'>Name</th><th width='30%'>Supplier</th><th width='20%'>End Date</th>"
div1.InnerHtml = ("<table width='96%' border='0' cellpadding='0' cellspacing='0' border='0' class='datatable1'>" & th) + tr & "</table>"
Else
div1.InnerHtml = "No results for your search"
End If
++UPDATE++
Thanks for your help
I've added a StringBuilder to my code instead of the string concatenation. However, the performance didn't change, so I assume the problem is somewhere else.
I forgot to mention in my previous email that the xml data I get comes from a Web service I am consuming. Is there anyhthing I can do to optimise this performance? Many thanks