Goshawk Posted August 30, 2007 Share Posted August 30, 2007 Hi all, I am new to programming and PHP, but I am currently writing a module for Zencart, where in a sidebox visitors can contact the store owner via Skype. I am currently getting this error: "Fatal error: Cannot instantiate non-existent class: xmlparser" This is the XML file I am trying to process: ================================================ <rdf:RDF> − <Status rdf:about="urn:skype:skype.com:skypeweb/1.1"> <statusCode rdf:datatype="http://www.skype.com/go/skypeweb">3</statusCode> <presence xml:lang="NUM">3</presence> <presence xml:lang="en">Away</presence> <presence xml:lang="fr">Absent</presence> <presence xml:lang="de">Abwesend</presence> <presence xml:lang="ja">一時退席中</presence> <presence xml:lang="zh-cn">暫時離開</presence> <presence xml:lang="zh-tw">离开</presence> <presence xml:lang="pt">Ausente</presence> <presence xml:lang="pt-br">Ausente</presence> <presence xml:lang="it">Torno subito</presence> <presence xml:lang="es">Ausente</presence> <presence xml:lang="pl">Zaraz wracam</presence> <presence xml:lang="se">Tillfälligt borta</presence> </Status> </rdf:RDF> ========================================== And this is what I have written so far: ========================================== <?php function print_error() { global $parser; die(sprintf("XML Error: %s at line %d", xml_error_string($xml_get_error_code($parser)), xml_get_current_line_number($parser) )); } //Get the XML document loaded into a variable $status = file_get_contents('http://mystatus.skype.com/SkypeNameHere.xml'); //Set up the parser object $parser = new XMLParser($status); $parser->Parse(); //Display the results { //If the rating is 2 if($presence->tagAttrs['NUM'] == '2') echo ('<a href="skype:SkypeNameHere?call"><img src="www.somewhere.com/images/online.gif" style="border: none;" width="140" height="56" alt="Available" /></a>'); //If the rating is not 2 if($presence->tagAttrs['NUM'] != '2') echo ('<img src="www.somewhere.com/images/not_online.gif" style="border: none;" width="140" height="56" alt="Not Available" />'); } ?> =================================================== Hope you can help me set this up. Kind regards, and many thanks, Goshawk Quote Link to comment https://forums.phpfreaks.com/topic/67287-parser-help-needed-to-process-xml-file-data/ Share on other sites More sharing options...
Jessica Posted August 30, 2007 Share Posted August 30, 2007 Well the class which defines XMLParser is not able to be accessed. Where is the class file for it included? Are you using this class: http://www.phpinsider.com/php/code/XMLParser/ As it says you need this code: require('XMLParser.class.php'); Quote Link to comment https://forums.phpfreaks.com/topic/67287-parser-help-needed-to-process-xml-file-data/#findComment-337566 Share on other sites More sharing options...
Goshawk Posted August 30, 2007 Author Share Posted August 30, 2007 I have not got one...Uhhh? I am new to this, so should I have a file called XMLParser.php? And what should it contain? Quote Link to comment https://forums.phpfreaks.com/topic/67287-parser-help-needed-to-process-xml-file-data/#findComment-337567 Share on other sites More sharing options...
Jessica Posted August 30, 2007 Share Posted August 30, 2007 Well, where did you get the code above? You obviously didn't write it as you don't know about the class you used. Quote Link to comment https://forums.phpfreaks.com/topic/67287-parser-help-needed-to-process-xml-file-data/#findComment-337569 Share on other sites More sharing options...
Goshawk Posted August 30, 2007 Author Share Posted August 30, 2007 The code comes from a mixture of the php manual and some learning modules I found online. I can call the file both in xml, txt or return a num value. What need to know is, once I have called that file, how do I process it contents, so I can create an output to display online. Quote Link to comment https://forums.phpfreaks.com/topic/67287-parser-help-needed-to-process-xml-file-data/#findComment-337607 Share on other sites More sharing options...
Jessica Posted August 30, 2007 Share Posted August 30, 2007 Did you look at the link I provided? It has the docs for the XMLParser. Quote Link to comment https://forums.phpfreaks.com/topic/67287-parser-help-needed-to-process-xml-file-data/#findComment-337612 Share on other sites More sharing options...
Goshawk Posted August 30, 2007 Author Share Posted August 30, 2007 Hi jesirose, Sorry I have not been in contact till now, but as you would have noticed, the server went down for a bit. As a newbie, I was looking for things far too complicated. Instead of the more complex xml file, I decided to call the data from a *.num file which gives a return of one digit (0, 1, 2, 3, 4, 5, 6). A return of '2' means that the user is online and available. I am only interested to know whether the user is available, so therefore I need to post only one of 2 replies; either 'available' or 'not available' Below is the simple code: <?php $content = file_get_contents("http://mystatus.skype.com/SkypeUserName.num"); if ($content == '2') echo '<a href="skype:SkypeUserName?call"><img src="./images/skype/online.gif" style="border: none;" width="140" height="56" alt="Available" /></a>'; if ($content != '2') echo '<img src="./images/skype/not_online.gif" style="border: none;" width="140" height="56" alt="Not Available" />'; ?> I now have encountered a second problem (beside the image not loading due to wrong url) and that is to define '$content' as seen in the code below. <?php $show_SkypeLive = true; if ($show_SkypeLive == true) { $content = ''; require($template->get_template_dir('tpl_SkypeLive.php',DIR_WS_TEMPLATE, $current_page_base,'sideboxes'). '/tpl_SkypeLive.php'); $content = #[color=red]what should I put here?[/color]; $title = BOX_HEADING_SkypeLive; $title_link = false; $left_corner = false; $right_corner = false; $right_arrow = false; require($template->get_template_dir($column_box_default, DIR_WS_TEMPLATE, $current_page_base,'common') . '/' . $column_box_default); } ?> The result of this code can be seen here: http://www.inekesfashions.com.au/wholesale/ As you can see, this code displays the results of the first line of code in the sidebox, and what I need to have displayed is shown above the sidebox. $content should also be 'class=sideBoxContent centerBoxContent' so that is displays according to the css. How must I define '$content' and how do I prevent the results to be displayed from '$content = file_get_contents("http://mystatus.skype.com/SkypeUserName.num");' Thanks for your time, Goshawk Quote Link to comment https://forums.phpfreaks.com/topic/67287-parser-help-needed-to-process-xml-file-data/#findComment-337672 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.