Post by jd_james » Fri Dec 16, 2011 3:33 am

Hi Guys,

I get an error stating:

XML tag mismatch
Your data feed contains a pair of opening/closing XML tags that do not match. A closing tag must always match the most recent opening tag in the feed. For example, this XML would generate an "XML Tag Mismatch" error:


So im trying to locate the file so i can see where the missing or open tag is , can someone shed some light?

Active Member

Posts

Joined
Fri Apr 15, 2011 10:55 pm

Post by jd_james » Fri Dec 16, 2011 4:11 am

seems to be:


XML formatting error - Error
Our system encountered an error when processing your data feed. Learn more.
Examples:

Line No. Column No.
6 82

Under opencart 1.5.1.3 - default files.
Last edited by jd_james on Fri Dec 16, 2011 4:53 am, edited 2 times in total.

Active Member

Posts

Joined
Fri Apr 15, 2011 10:55 pm

Post by uksitebuilder » Mon Dec 19, 2011 8:18 pm

your last error means you have invalid non-UTF-8 characters in your description or product name

probably due to copying/pasting the description from another source or MS Word etc.

User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by Qphoria » Mon Dec 19, 2011 10:48 pm

It's a bug in the feed.
To fix:

1. EDIT:
catalog/controller/feed/google_base.php

2. FIND:

Code: Select all

$output .= '<title>' . html_entity_decode($product['name'], ENT_QUOTES, 'UTF-8') . '</title>';
3. REPLACE WITH:

Code: Select all

$output .= '<title>' . $product['name'] . '</title>';

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by jd_james » Mon Dec 19, 2011 11:42 pm

Thanks for the reply guys

it still doesnt like my code for some reason unless it is to do with the copying and pasting from my word doc? Thats what i do is there another recommended method then?

XML formatting error - Error
Our system encountered an error when processing your data feed. Learn more.
Examples:
Line No.
6
Column No.
82


Code: Select all

<?php class ControllerFeedGoogleBase extends Controller {
	public function index() {
		if ($this->config->get('google_base_status')) { 
			$output  = '<?xml version="1.0" encoding="UTF-8" ?>';
			$output .= '<rss version="2.0" xmlns:g="http://base.google.com/ns/1.0">';
            $output .= '<channel>';
			$output .= '<title>' . $this->config->get('config_name') . '</title>'; 
			$output .= '<description>' . $this->config->get('config_meta_description') . '</description>';
			$output .= '<link>' . HTTP_SERVER . '</link>';
			
			$this->load->model('catalog/category');
			
			$this->load->model('catalog/product');
			
			$this->load->model('tool/image');
			
			$products = $this->model_catalog_product->getProducts();
			
			foreach ($products as $product) {
				if ($product['description']) {
					$output .= '<item>';
					$output .= '<title>' . $product['name'] . '</title>';
					$output .= '<link>' . $this->url->link('product/product', 'product_id=' . $product['product_id']) . '</link>';
					$output .= '<description>' . strip_tags(html_entity_decode($product['description'], ENT_QUOTES, 'UTF-8')) . '</description>';
					$output .= '<g:brand>' . html_entity_decode($product['manufacturer'], ENT_QUOTES, 'UTF-8') . '</g:brand>';
					$output .= '<g:condition>new</g:condition>';
					$output .= '<g:id>' . $product['product_id'] . '</g:id>';
					
					if ($product['image']) {
						$output .= '<g:image_link>' . $this->model_tool_image->resize($product['image'], 500, 500) . '</g:image_link>';
					} else {
						$output .= '<g:image_link>' . $this->model_tool_image->resize('no_image.jpg', 500, 500) . '</g:image_link>';
					}
					
					$output .= '<g:mpn>' . $product['model'] . '</g:mpn>';

					$supported_currencies = array('USD', 'EUR', 'GBP');

                    if (in_array($this->currency->getCode(), $supported_currencies)) {
                        $currency = $this->currency->getCode();
                    } else {
                        $currency = ($this->config->get('google_base_status')) ? $this->config->get('google_base_status') : 'USD';
                    }
									
					if ((float)$product['special']) {
                        $output .= '<g:price>' .  $this->currency->format($this->tax->calculate($product['special'], $product['tax_class_id']), $currency, FALSE, FALSE) . '</g:price>';
                    } else {
                        $output .= '<g:price>' . $this->currency->format($this->tax->calculate($product['price'], $product['tax_class_id']), $currency, FALSE, FALSE) . '</g:price>';
                    }
			   
					$categories = $this->model_catalog_product->getCategories($product['product_id']);
					
					foreach ($categories as $category) {
						$path = $this->getPath($category['category_id']);
						
						if ($path) {
							$string = '';
							
							foreach (explode('_', $path) as $path_id) {
								$category_info = $this->model_catalog_category->getCategory($path_id);
								
								if ($category_info) {
									if (!$string) {
										$string = $category_info['name'];
									} else {
										$string .= ' > ' . $category_info['name'];
									}
								}
							}
						 
							$output .= '<g:product_type>' . $string . '</g:product_type>';
						}
					}
					
					$output .= '<g:quantity>' . $product['quantity'] . '</g:quantity>';
					$output .= '<g:upc>' . $product['upc'] . '</g:upc>'; 
					$output .= '<g:weight>' . $this->weight->format($product['weight'], $product['weight_class']) . '</g:weight>'; 
					$output .= '</item>';
				}
			}
			
			$output .= '</channel>'; 
			$output .= '</rss>';	
			
			$this->response->addHeader('Content-Type: application/rss+xml');
			$this->response->setOutput($output);
		}
	}
	
	protected function getPath($parent_id, $current_path = '') {
		$category_info = $this->model_catalog_category->getCategory($parent_id);
	
		if ($category_info) {
			if (!$current_path) {
				$new_path = $category_info['category_id'];
			} else {
				$new_path = $category_info['category_id'] . '_' . $current_path;
			}	
		
			$path = $this->getPath($category_info['parent_id'], $new_path);
					
			if ($path) {
				return $path;
			} else {
				return $new_path;
			}
		}
	}		
}
?>

Active Member

Posts

Joined
Fri Apr 15, 2011 10:55 pm
Who is online

Users browsing this forum: No registered users and 2 guests