473,394 Members | 1,971 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

shorten load time for xml file

Hi

I have the below code. It works fine but it takes a long time to load on the browser page. Is there anything I can do to shorten this time?

Also, I would like to search the file for documents with NAME starting with A, B, C, etc. How do I do that?

Thanks for your help!

aspx.vb page

Expand|Select|Wrap|Line Numbers
  1. Dim xdoc As New XPathDocument(xt)
  2.  
  3.  
  4.         Dim nav As XPathNavigator = xdoc.CreateNavigator()
  5.  
  6.         Dim expr As XPathExpression
  7.         expr = nav.Compile("/pf:CONTRACTS/pf:CONTRACT")
  8.  
  9.         Dim namespaceManager As XmlNamespaceManager = New XmlNamespaceManager(nav.NameTable)
  10.         namespaceManager.AddNamespace("pf", "http://namespace/")
  11.  
  12.      expr.SetContext(namespaceManager)
  13.  
  14.         Dim nodes As XPathNodeIterator = nav.Select(expr)
  15.  
  16.     If nodes.Count <> 0 Then
  17.  
  18.             Dim tr As String = Nothing
  19.  
  20.             For Each node As XPathNavigator In nodes
  21.  
  22.           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>"
  23.  
  24.          For Each subNode2 As XPathNavigator In node.Select("pf:SUPPLIERS/pf:SUPPLIER", namespaceManager)
  25.  
  26.                     tr += "<td>" & subNode2.SelectSingleNode("pf:SUPPLIERNAME", namespaceManager).Value & "</td>"
  27.  
  28.                 Next
  29.  
  30.                 tr += "<td>" & node.SelectSingleNode("pf:ENDDATE", namespaceManager).Value & "</td>"
  31.  
  32.                 tr += "</tr>"
  33.  
  34.             Next
  35.  
  36.             Dim th As String = "<th width='50%'>Name</th><th width='30%'>Supplier</th><th width='20%'>End Date</th>"
  37.  
  38.             div1.InnerHtml = ("<table width='96%' border='0' cellpadding='0' cellspacing='0' border='0' class='datatable1'>" & th) + tr & "</table>"
  39.  
  40.         Else
  41.  
  42.             div1.InnerHtml = "No results for your search"
  43.  
  44.         End If

aspx page

Expand|Select|Wrap|Line Numbers
  1. <div id="div1" runat="server" >   </div>
Mar 3 '10 #1
3 1923
jkmyoung
2,057 Expert 2GB
I think the biggest problem is the string concatenation, eg using += or &. It's probably used thousands of times.

Everytime a concatenation operator is used, the string containing the results so far is resized, and possibly reallocated/copied/destroyed. Try and estimate the size of your output beforehand by using node counts, and allocate a stringbuilder object accordingly.

tips:
Create your own string concat object
VB StringBuilder class

Further question: Are you allowed to expose the source data to your clients?
Mar 3 '10 #2
Hi

Thank you very much. I will use your idea.

Sorry, what do you mean with to be "allowed to expose the source data to your clients".

I am new at .net and xml and any help will be appreciated.
Mar 3 '10 #3
jkmyoung
2,057 Expert 2GB
There were some other methods I could think of, which would have needed client access to your source data, but on further investigation, they're much slower.
Mar 4 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

27
by: Mike MacSween | last post by:
Some of my users are getting 'Disk or Network Errors'. I've raised it with the network admins, they're looking into it. In the meantime... My 'standard' error handlers logs errors to a table...
15
by: Benjamin Rutt | last post by:
Are there any C tools that can find redundant #includes in a project, so as to shorten compile time? Of course, eliminating single #includes by hand and determining if the recompile fails is one...
8
by: ben | last post by:
i have a bit of code, that works absolutely fine as is, but seems over complicated/long winded. is there anyway to shorten/simplify it? the code is below. description of it: it's like strcpy in...
24
by: John Smith | last post by:
I want to shorten a string by replacing the last character by '\0'. The following code displays the string. It works fine. It's in a loop and different strings are displayed without problems....
1
by: Web Response Time | last post by:
I found a surprising problem. I sent a zero length's request in my asp.net program to another asp.net program on the local machine. until I received the zero length's response data, it only took...
4
by: Ravi Ambros Wallau | last post by:
Hi: We developed a set of ASP.NET Web Applications that never runs in stand-alone mode, but always inside a portal (Rainbow Portal). All modules are copied on that portal. My question is: load...
6
by: jrthor2 | last post by:
I have a shell script I am trying to run that loads a table from a control file. The file I am trying to load is delimited by the "}" character. How do I set the delimeter code? Here is my load...
1
by: huyuhui | last post by:
The following is a question of LOAD utility. Question: How does the DB2 enforce table check constraints for data added to table with the LOAD utility? A. With the BUILD phase of LOAD B. With the...
2
by: David Thielen | last post by:
So we have moved our app from .NET version 2.X in IIS6 to a Windows 2008 Server running IIS7. We have copied all files to the Windwardreports\apps directory and that apps directory has been...
13
by: rdudejr | last post by:
Hi all, I hardly ever make a post unless I am having a very purplexing issue, so this one should be good... I am trying to do a load against a database on an AIX server into a DB2 v9.1...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.