久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如何輕松調(diào)試布局 Xml 警告/錯誤?

How to easily Debug Layout Xml Warning/Error?(如何輕松調(diào)試布局 Xml 警告/錯誤?)
本文介紹了如何輕松調(diào)試布局 Xml 警告/錯誤?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我被這個錯誤卡住了:

Warning: simplexml_load_string(): Entity: line 46: parser error : Comment not terminated  in */lib/Varien/Simplexml/Config.php on line 510

Entity: line 46: parser error : Start tag expected, '<' not found  in */lib/Varien/Simplexml/Config.php on line 510

很明顯一些Xml文件有問題,但我真的不容易在大海撈針中找出針:)

It is clear that there is an issue in some Xml file, but really not easy for me to find out the needle in the big haystack :)

對此有什么好的做法嗎?如果可能的話,我想找到一個涉及使用 Xdebug 或一些日志的好習(xí)慣.

Any good practice for that? If possible I would like to find a good practice that involves use Xdebug, or some log.

在 Magento 中經(jīng)常會出現(xiàn)拼寫錯誤.

It happens a lot of time in Magento to do some miss spelling.

推薦答案

我覺得你可以看看這篇文章 處理 XML 錯誤.

I think you can take a look at this article Dealing with XML errors.

此警告與一些 config.xml 錯誤有關(guān),因此找出確切文件的可能解決方法是修改./lib/Varien/Simplexml/Config.php 類.

This warning is related to some config.xml error, so a possible workaround to find out the exact file is to mod. the /lib/Varien/Simplexml/Config.php class.

你應(yīng)該修改Varien_Simplexml_Config::loadString()方法:

public function loadString($string)
{
    if (is_string($string)) {
        // Enable internal errors
        libxml_use_internal_errors(true);
        $xml = simplexml_load_string($string, $this->_elementClass);
        if (false === $xml) {
            // Put breakpoint here
            $errors = libxml_get_errors();
        }
        if ($xml instanceof Varien_Simplexml_Element) {
            $this->_xml = $xml;
            return true;
        }
    } else {
        Mage::logException(new Exception('"$string" parameter for simplexml_load_string is not a string'));
    }
    return false;
}

如果錯誤與某些布局文件有關(guān)(Update.php line 444 警告)

In case the error is related to some Layout file ( Update.php line 444 warning )

您應(yīng)該以類似的方式修改 Mage_Core_Model_Layout_Update::getFileLayoutUpdatesXml() 方法:

You should modify Mage_Core_Model_Layout_Update::getFileLayoutUpdatesXml() method in a similar way:

public function getFileLayoutUpdatesXml($area, $package, $theme, $storeId = null)
{
    if (null === $storeId) {
        $storeId = Mage::app()->getStore()->getId();
    }
    /* @var $design Mage_Core_Model_Design_Package */
    $design = Mage::getSingleton('core/design_package');
    $layoutXml = null;
    $elementClass = $this->getElementClass();
    $updatesRoot = Mage::app()->getConfig()->getNode($area.'/layout/updates');
    Mage::dispatchEvent('core_layout_update_updates_get_after', array('updates' => $updatesRoot));
    $updateFiles = array();
    foreach ($updatesRoot->children() as $updateNode) {
        if ($updateNode->file) {
            $module = $updateNode->getAttribute('module');
            if ($module && Mage::getStoreConfigFlag('advanced/modules_disable_output/' . $module, $storeId)) {
                continue;
            }
            $updateFiles[] = (string)$updateNode->file;
        }
    }
    // custom local layout updates file - load always last
    $updateFiles[] = 'local.xml';
    $layoutStr = '';
    foreach ($updateFiles as $file) {
        $filename = $design->getLayoutFilename($file, array(
            '_area'    => $area,
            '_package' => $package,
            '_theme'   => $theme
        ));
        if (!is_readable($filename)) {
            continue;
        }
        $fileStr = file_get_contents($filename);
        $fileStr = str_replace($this->_subst['from'], $this->_subst['to'], $fileStr);   


        libxml_use_internal_errors(true);
        $fileXml = simplexml_load_string($fileStr, $elementClass);


        if (false === $fileXml) {
            // Put breakpoint here
            $errors = libxml_get_errors();
            $err = array($filename, $errors);
            // error detail and file name will be printed
            Zend_Debug::dump($err);
            die();
        }



        if (!$fileXml instanceof SimpleXMLElement) {
            continue;
        }
        $layoutStr .= $fileXml->innerXml();
    }
    $layoutXml = simplexml_load_string('<layouts>'.$layoutStr.'</layouts>', $elementClass);
    return $layoutXml;
}

現(xiàn)在只需重新加載頁面并讀取錯誤信息.

Now just reload the page a read the error info.

這篇關(guān)于如何輕松調(diào)試布局 Xml 警告/錯誤?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

How to add a custom text field in Magento v1.5 Catalog/Mange products/General tab in admin panel?(如何在管理面板的 Magento v1.5 Catalog/Mange products/General 選項卡中添加自定義文本字段?) - IT屋-程序員軟件開發(fā)技術(shù)
Getting pager to show on magento list(讓尋呼機顯示在 magento 列表中)
Magento: how to load product along its all data as it is used in admin(Magento:如何加載產(chǎn)品及其在管理中使用的所有數(shù)據(jù))
Create a new table from magento module(從 magento 模塊創(chuàng)建一個新表)
Magento Customer Grid - Mask Email address(Magento 客戶網(wǎng)格 - 屏蔽電子郵件地址)
Magento call cms page through anchor tag from phtml file(Magento 通過 phtml 文件中的錨標(biāo)記調(diào)用 cms 頁面)
主站蜘蛛池模板: 日本福利视频免费观看 | 国产三区在线观看视频 | 久久久999精品 | 国产一区二区精品在线 | 欧美伊人影院 | 国产色片 | 日韩免费网站 | av黄色免费| 亚洲欧美日韩国产综合 | 黄色片在线看 | 欧美男人天堂 | 国产免费视频在线 | 亚洲网在线 | 午夜国产羞羞视频免费网站 | 国产一区二区三区视频免费观看 | 免费黄色日本 | 国产精品久久国产精品 | 欧美精品久久一区 | 欧美日韩亚洲一区二区 | h视频在线观看免费 | 国产蜜臀97一区二区三区 | 色综合久久久久 | 二区三区在线观看 | 欧美日韩在线免费 | 国产精品久久久久久久久久久久 | 国产在线中文字幕 | 国产精品波多野结衣 | 黄色一级视频免费 | 国产乱码精品一区二区三区五月婷 | 久热中文字幕 | 国产精品一区二区三 | 欧美一区二区三区视频在线观看 | 亚洲成av| a中文在线视频 | 91人人澡人人爽 | 麻豆av在线| 国产精品精品视频一区二区三区 | 天天操天天拍 | 午夜精品 | 亚洲精选一区二区 | 成人福利在线观看 |