PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, August 31, 2022

[FIXED] How to solve the SimpleXMLElement error?

 August 31, 2022     apc, centos, pear, php, zend-framework     No comments   

Issue

I have a very strange error, and cant fix it. Tried to install APC, PEAR but same error continue. How to solve this any idea?

[error] [client 127.0.0.1] PHP Warning: SimpleXMLElement::__construct(): Entity: line 9: parser error : Comment not terminated in /var/www/html/my/application/search/models/Search/Adapter/Web/YahooBoss.php on line 39

<?php

class Search_Adapter_Web_YahooBoss extends Search_Adapter_Abstract implements Search_Adapter_Localized_Interface {

    private $_applicationId;
    private $_locale;
    private $_defaultLocale = 'en_US';

    function __construct($applicationId) {
        $this->_applicationId = $applicationId;
    }

    /**
     * @param $searchString string
     * @param $offset integer
     * @param $count integer
     * @return Search_ResultList
     */
    public function search($searchString, $offset, $count) {
        $rest = new Zend_Rest_Client ( 'http://boss.yahooapis.com' );

            ///Zend_Debug::dump($rest);exit;

        //Set the locale for internal use
        $locale = $this->getWorkingLocale();
        $options = array ('region' => $locale->getRegion (), 'lang' => $locale->getLanguage (), 'start' => $offset, 'count' => $count,'type'=>'html', 'format' => 'xml', 'appid' => $this->_applicationId );

        // < and > characters cause errors
        $searchString = str_replace(array('<','>'),'',$searchString);

        $restUrl = '/ysearch/web/v1/' . rawurlencode ( $searchString );
        $response = $rest->restGet ($restUrl , $options);

        if ($response->isError ()) {
            require_once 'Zend/Service/Exception.php';
            throw new Zend_Service_Exception ( 'An error occurred sending request. Status code: ' . $response->getStatus () );
        }

        $body = $response->getBody ();
        //libxml_use_internal_errors(true);
        $sxe = new SimpleXMLElement ( $body );




# php -r 'phpinfo();' |grep apc
Additional .ini files parsed => /etc/php.d/apc.ini,
apc
MMAP File Mask => /tmp/apc.XXXXXX
apc.cache_by_default => On => On
apc.canonicalize => Off => Off
apc.coredump_unmap => Off => Off
apc.enable_cli => Off => Off
apc.enabled => On => On
apc.file_md5 => Off => Off
apc.file_update_protection => 2 => 2
apc.filters => no value => no value
apc.gc_ttl => 3600 => 3600
apc.include_once_override => Off => Off
apc.lazy_classes => Off => Off
apc.lazy_functions => Off => Off
apc.max_file_size => 1M => 1M
apc.mmap_file_mask => /tmp/apc.XXXXXX => /tmp/apc.XXXXXX
apc.num_files_hint => 1024 => 1024
apc.preload_path => no value => no value
apc.report_autofilter => Off => Off
apc.rfc1867 => Off => Off
apc.rfc1867_freq => 0 => 0
apc.rfc1867_name => APC_UPLOAD_PROGRESS => APC_UPLOAD_PROGRESS
apc.rfc1867_prefix => upload_ => upload_
apc.rfc1867_ttl => 3600 => 3600
apc.serializer => default => default
apc.shm_segments => 1 => 1
apc.shm_size => 64M => 64M
apc.slam_defense => On => On
apc.stat => On => On
apc.stat_ctime => Off => Off
apc.ttl => 7200 => 7200
apc.use_request_time => On => On
apc.user_entries_hint => 4096 => 4096
apc.user_ttl => 7200 => 7200
apc.write_lock => On => On

Solution

I think your problem is caused by the XML stream you are trying to load : it does not seem to be valid xml.

If it is a webpage, try to get the source code and validate it with the w3c validator. In ordre to work with simplexml, it must be compatible with the xhtml strict format.

If it is an XML stream (from an api for example), Check if it is well formed (you may use any major IDE that supports XML



Answered By - Benjamin Dubois
Answer Checked By - Gilberto Lyons (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing