View Full Version : PHP and XML speed problem

02-09-2006, 01:42 PM
Hi everyone. I am building a website that performs some requests to another server, retrieves the information and then displays it. The requests are made with XML files that are dynamically created from my page. My website works like this:

There is one page with a form where the user must enter the search criteria. Then the form posts the user entered data to another webpage.

The second webpage puts them into an XML, posts it using cURL and stores the response into a string variable. The variable then is parsed with PHP’s simple XML and echoes them.

The problem is that went the second page loads, the status bar say that the page is loaded while the page seems blank. After a while the page starts to load again and the displays the retrieved data. I tried to find out why this happens and I erased everything except from the XML that is posted and the cURL code that posts it and assigns the response to a variable, so I came up with the conclusion that cURL is responsible. The XML that I send is about 15 to 20 lines long and it’s well formatted so I don’t think the XML is the problem, but the response XML might be huge depending on the search data entered.

Can anyone tell me how to fix this problem or how to display a “Loading…” or something while the page seems blank? I’m sorry for the huge post. Thanks in advance!

02-09-2006, 04:40 PM
is the result displayed in a table (an html table)?

02-09-2006, 04:52 PM
Hi. Thanks for the reply. I echo a table. Inside the table there are some variables to output the the results i parsed with simple XML from the response XML. The table i repeated in order to display all the results. I stored the response XML in a file and parsed it localy to see if the parser is my problem but i had no delay. When i receive a response from the remote server i have a different delay time every time i make a new query. I think my code and the XML i send are well writen. What could be the problem? Thanks again!

02-09-2006, 05:01 PM
is it a large table? because a table will only be displayed when it's completely loaded into the browser. first the browser will load the complete code for the table and usually will then rerender the page (which you can see sometimes when the pages stretches etc)

Maybe the problem is that the content isn't streamed quick enough to the client and/or rendered fast enough by the browser.

try just echoing out the response, without putting it into a table. You might then get a page that starts displaying content as soon as html code is received (depending on what browser you use, of course)

02-09-2006, 05:10 PM
I deleted everything and left only the curl function that posts the XML and i echoed the response XML but i had a delay once more. There are only 40 lines of code left. I don't think that this is the case. Thanks for the quick reply.

02-09-2006, 05:28 PM
did you try echoing the microtime at strategical positions in your code to get an idea on the duration of each step?

code for a timer --> http://www.codingforums.com/showthread.php?t=38659&highlight=timer+function