Can't flush() text/xml type?
Moderator: General Moderators
Can't flush() text/xml type?
I have a script that is querying a mysql DB and throwing back the results via <table>,<tr>,<td>'s . The result set may be very large so after each </tr> or </table> I issue a flush() or ob_flush() and everything works perfectly to keep impatient users seeing additional data rather then a blank screen.
However once i converted to returning the results in xml 1.0 it seems to break the ability to flush() and the page will not display until the entire results are returned. Specifically the:
header("Content-Type: text/xml;charset=ISO-8859-1");
seems to break all flush()'s. Is there any way to output buffer the xml formatted results without having to go an ajax route?
Thank in advance for anyone who may be able to help or offer advice.
However once i converted to returning the results in xml 1.0 it seems to break the ability to flush() and the page will not display until the entire results are returned. Specifically the:
header("Content-Type: text/xml;charset=ISO-8859-1");
seems to break all flush()'s. Is there any way to output buffer the xml formatted results without having to go an ajax route?
Thank in advance for anyone who may be able to help or offer advice.
The result set is dynamic (pre-filtered) based on the user input prior to the results being provided. Paging would be counter productive as the full result set is actually what they are looking to see. The issue I have is if I can actually flush() when the content type is xml ? Ive searched high & low and cant find anything related 
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
Why are you using <table> et al in an XML file? While technically they are perfectly valid XML, wouldn't it be better to use descriptive element names?
I would hazard to guess that the browser is waiting for the container to finish before it tries to display information about it. I think it may be better to use a different tag structure.
I would hazard to guess that the browser is waiting for the container to finish before it tries to display information about it. I think it may be better to use a different tag structure.
The script originally was set up via std. html tables/tr/td layout. Once I converted it to deliver xml I used descriptive element names and employ xslt transformation to control the presentation. So the resultset is strictly xml, however the xsl applies the display logic. Back to the issue at hand lol is there a way to spit out each node rather then the whole container ?
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
feyd | Please use
This is generated within a for loop -> psuedo code:[/syntax]
this is just a faaux sample of whats being done... but illustrates the goal..... when done in XHTML <TABLE><TR><TD> it works as desired spitting out one row after another withe each flush(). However once I change to text/xml and spit out xml fields.... no dice.
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I use output buffering because part of the result set contains hyperlinks which may be clicked on. It is necessary that the results are written out as they are generated because some of the results may be quite large and it serves to allow the user to begin clicking away as others are populated ; instead of waiting 2-3 minutes for it to complete.
More Specifically:
Example XML:
[syntax="xml"]<ROOT>
<ELEMENT>
<ID>100</ID>
<URL>http://www.yahoo.com</URL>
<VALUE>$50.00</value>
</ELEMENT>
<ELEMENT>
<ID>100</ID>
<URL>http://www.google.com</URL>
<VALUE>$75.00</value>
</ELEMENT>
<ELEMENT>
<ID>100</ID>
<URL>http://www.msn.com</URL>
<VALUE>$25.00</value>
</ELEMENT>
</ROOT>This is generated within a for loop -> psuedo code:[/syntax]
Code: Select all
echo "<ROOT>/r/n";
for ($i=0; $i <=$max; $i++){
echo "<ELEMENT>/r/n<ID>".$id."</ID>/r/n<URL>".$url."</URL>/r/n<VALUE>".$value."</VALUE>/r/n</ELEMENT>/r/r";
@ob_flush;
flush();
}
echo "</ROOT>/r/n";this is just a faaux sample of whats being done... but illustrates the goal..... when done in XHTML <TABLE><TR><TD> it works as desired spitting out one row after another withe each flush(). However once I change to text/xml and spit out xml fields.... no dice.
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]