php &xml

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • th1982
    New Member
    • Feb 2008
    • 51

    php &xml

    I've a ticker's code like this :


    [PHP]<?php
    // load SimpleXML
    $SECURITIES = new SimpleXMLElemen t('http://www.zet.com/xml/TableDt.xml', null, true);

    echo <<<EOF
    <marquee bgcolor="#33333 3" scrollamount="3 " onmouseover=sto p() onmouseout=star t() ><font face='Time News Romance' font color='white' font size=4><table>


    EOF;

    foreach($SECURI TIES as $STOCK) // loop
    {
    $change=$STOCK->Change;

    echo "SYMBOL:{$S TOCK->Symbol_code}&n bsp;&nbsp;&nbsp ;&nbsp;&nbsp; ";
    echo "PRICE:{$ST OCK->Price}&nbsp;&n bsp;&nbsp;&nbsp ;&nbsp;";

    if($change==0)
    {
    echo "<img src='vang.gif'> $change</img>&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp;&nbsp;";
    }
    else
    {
    if($change>0)
    {
    echo "<img src='gre (2).gif'>$chang e</img>&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp;&nbsp;
    &nbsp;&nbsp;&nb sp;&nbsp;&nbsp; &nbsp;";
    }
    else
    {
    if($change<0)
    {
    echo "<img src='red.gif'>$ change</img>&nbsp;&nbsp ;&nbsp;&nbsp;&n bsp;
    &nbsp;&nbsp;&nb sp;&nbsp;&nbsp; &nbsp;&nbsp; ";
    }
    }
    }




    }
    echo '</table></marquee>';

    ?>[/PHP]


    it's fine if my xml file is not updated.Now my xml file is updated every 30 seconds,so it get error like this:


    Warning: SimpleXMLElemen t::__construct( ) [function.Simple XMLElement---construct]: http://purpleasia.com/clients/xml/b...bleDt.xml:2309: parser error : expected '>' in C:\wamp\www\VFM website\VFM_tes t\ticker.php on line 4

    Warning: SimpleXMLElemen t::__construct( ) [function.Simple XMLElement---construct]: <Best2Bid>26</Best2 in C:\wamp\www\VFM website\VFM_tes t\ticker.php on line 4

    Warning: SimpleXMLElemen t::__construct( ) [function.Simple XMLElement---construct]: ^ in C:\wamp\www\VFM website\VFM_tes t\ticker.php on line 4

    Warning: SimpleXMLElemen t::__construct( ) [function.Simple XMLElement---construct]: http://purpleasia.com/clients/xml/b...bleDt.xml:2309: parser error : Opening and ending tag mismatch: Best2Bid line 2309 and Best2 in C:\wamp\www\VFM website\VFM_tes t\ticker.php on line 4

    Warning: SimpleXMLElemen t::__construct( ) [function.Simple XMLElement---construct]: <Best2Bid>26</Best2 in C:\wamp\www\VFM website\VFM_tes t\ticker.php on line 4

    Warning: SimpleXMLElemen t::__construct( ) [function.Simple XMLElement---construct]: ^ in C:\wamp\www\VFM website\VFM_tes t\ticker.php on line 4

    Warning: SimpleXMLElemen t::__construct( ) [function.Simple XMLElement---construct]: http://purpleasia.com/clients/xml/b...bleDt.xml:2309: parser error : Premature end of data in tag STOCK line 2298 in C:\wamp\www\VFM website\VFM_tes t\ticker.php on line 4

    Warning: SimpleXMLElemen t::__construct( ) [function.Simple XMLElement---construct]: <Best2Bid>26</Best2 in C:\wamp\www\VFM website\VFM_tes t\ticker.php on line 4

    Warning: SimpleXMLElemen t::__construct( ) [function.Simple XMLElement---construct]: ^ in C:\wamp\www\VFM website\VFM_tes t\ticker.php on line 4

    Warning: SimpleXMLElemen t::__construct( ) [function.Simple XMLElement---construct]: http://purpleasia.com/clients/xml/b...bleDt.xml:2309: parser error : Premature end of data in tag SECURITIES line 1 in C:\wamp\www\VFM website\VFM_tes t\ticker.php on line 4

    Warning: SimpleXMLElemen t::__construct( ) [function.Simple XMLElement---construct]: <Best2Bid>26</Best2 in C:\wamp\www\VFM website\VFM_tes t\ticker.php on line 4

    Warning: SimpleXMLElemen t::__construct( ) [function.Simple XMLElement---construct]: ^ in C:\wamp\www\VFM website\VFM_tes t\ticker.php on line 4

    Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in C:\wamp\www\VFM website\VFM_tes t\ticker.php:4 Stack trace: #0 C:\wamp\www\VFM website\VFM_tes t\ticker.php(4) : SimpleXMLElemen t->__construct('h ttp://purpleas...', 0, true) #1 {main} thrown in C:\wamp\www\VFM website\VFM_tes t\ticker.php on line 4

    it have no problem from the link(link had given only for ex)
    i get this xml file from the host and it will be updated from third party any morning from 7am-11am,this time my php page get error like that.(but it's ok when i refresh few times ,if refresh again ,again get error)
    if dont have any solution for this can we hide the error page and appear a message :"loading page..." . can we do that?
    thanks so much

    Pls help me to solve this problem.Thank you so much
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    I think it's got something to do with the heredoc type variable. I'm not familiar there but if the XML gets to see <<<EOF this will cause the opening/ending tag mismatch.

    Comment

    Working...