Error type: LoadXML Description: Incorrect XML

Home Forums CRE Loaded Support CRE Loaded 6.4 Error type: LoadXML Description: Incorrect XML

This topic contains 17 replies, has 0 voices, and was last updated by  NatTack 8 years, 7 months ago.

  • Author
    Posts
  • #28634

    NatTack
    Participant

    I receive the following error when adding a coupon.

    Error type: LoadXML
    Description: Incorrect XML

    This happens when I try to either assign Valid Categories or Valid Products to that coupon. The pop-up window open which usually has products or categories to pick from.

  • #122716

    aitsglobal
    Participant

    in admin/get_categories.php you will see a function


    function str_rep($row){
    $row = str_replace('&', '&', $row);
    $row = str_replace('&', '&', $row);
    $row = str_replace('>', '>', $row);
    $row = str_replace('<', '<', $row);
    //ADD THIS FIX
    $row = str_replace('"', ' ', $row);
    //ADD THIS FIX
    return $row;

    You might be using ” or ‘ in the title of the Categories or Products either remove them from the titles or clean them. Hope this will solve your problem.

  • #122717

    NatTack
    Participant

    Thanks
    I checked my code and compared to the code you sent

    //ADD THIS FIX
    $row = str_replace(‘”‘, ‘ ‘, $row);
    //ADD THIS FIX
    return $row;

    It was missing the two fixes so I added it and it fixed the problem.

    Thanks again

  • #122718

    aitsglobal
    Participant

    😀

  • #122719

    NatTack
    Participant

    Darn I spoke too soon, it is still broken I was looking at the wrong page.

    Any additional help?

  • #122720

    aitsglobal
    Participant

    post the error you are getting.

  • #122721

    NatTack
    Participant

    Error type: LoadXML
    Description: Incorrect XML

    This happens when I try to either assign Valid Categories or Valid Products to a new coupon. The pop-up window open which usually has products or categories to pick from.

  • #122722

    aitsglobal
    Participant

    Please check your categories and products titles there must be some special character causing problem. You can also call out the script directly which will provide with pure xml output you can zip and send it I might be able to help you.

    http://yourdomain.com/admin/get_categories.php

  • #122723

    NatTack
    Participant

    I get the following error when I run /admin/get_categories.php

    XML Parsing Error: not well-formed
    Location: /admin/get_categories.php
    Line Number 555, Column 26:


    ^

  • #122724

    NatTack
    Participant

    Well it seems there are hundreds if not thousands of products the have a quote ” in them to show inch. I guess i need to edit them.

  • #122725

    TheLango
    Participant

    You can try this, rather than renaming all your products..

    In get_categories.php, look for the function str_rep($row){
    , rename it to function str_rep1($row){

    Paste the following code just above this function.


    function str_rep($row, $quote_style = ENT_QUOTES, $charset = 'UTF-8')
    {
    if (is_array($row)) {
    foreach($row as $key => $value) {
    $row[$key] = htmlspecialchars_deep($value, $quote_style, $charset);
    }
    } elseif (is_string($row)) {
    $row = htmlspecialchars(htmlspecialchars_decode($row, $quote_style), $quote_style, $charset);
    }
    return $row;
    }

    so you end up with :

    function str_rep($row, $quote_style = ENT_QUOTES, $charset = 'UTF-8')
    {
    if (is_array($row)) {
    foreach($row as $key => $value) {
    $row[$key] = htmlspecialchars_deep($value, $quote_style, $charset);
    }
    } elseif (is_string($row)) {
    $row = htmlspecialchars(htmlspecialchars_decode($row, $quote_style), $quote_style, $charset);
    }
    return $row;
    }
    function str_rep1($row){
    $row = str_replace('&', '&', $row);
    $row = str_replace('&', '&', $row);
    $row = str_replace('>', '>', $row);
    $row = str_replace('<', '<', $row);
    return $row;
    }

    This will allow the XML to complete, on removing the WHOLE product name where there is a special character it cant replace.

    eg.. Product name = Penne á Candela Pasta from Naples 500g returns an empty product name because of the á
    So, I ran the get_categories.php, with the replacement function str_rep, went through it, noting all products without a product name, just id.
    eg..<item text=“” id=”p_6102″ im0=”leaf.gif” im1=”leaf.gif” im2=”leaf.gif”/>
    then looked to find the offending character, replacing it using the following function, as I believe, the only replacement that takes place using the original function, is the last one in the order, so I ended up with the following.

    function str_rep1($row, $quote_style = ENT_QUOTES, $charset = 'UTF-8')
    {
    if (is_array($row)) {
    foreach($row as $key => $value) {
    $row[$key] = htmlspecialchars_deep($value, $quote_style, $charset);
    }
    } elseif (is_string($row)) {
    $row = htmlspecialchars(htmlspecialchars_decode($row, $quote_style), $quote_style, $charset);
    }
    return $row;
    }
    function str_rep($row){

    $spec_cs = array('ú', 'î', 'á', 'é', '£'); // These are the only Special Characters I needed to replace!!
    $specialarray=array('ú', 'í', 'á', 'é', '£');
    $row1 = str_replace($spec_cs, $specialarray, $row);

    $row = str_rep1($row1);
    return $row;

    Hope this helps..

  • #122726

    aitsglobal
    Participant

    This works most of the time try it

    line no 10 replace the encoding to utf16

    echo '' . "n";

    replace the function:


    function str_rep($row){
    $row = str_replace('&', '&', $row);
    $row = str_replace('&', '&', $row);
    $row = str_replace('>', '>', $row);
    $row = str_replace('<', '<', $row);
    $row = str_replace('"', '"', $row);
    $row = str_replace("'", " ", $row);
    $row = str_replace("/", " ", $row);
    $row = str_replace("£", "&#0163", $row);
    return $row;
    }
  • #122727

    NatTack
    Participant

    @thelango wrote:

    You can try this, rather than renaming all your products..

    In get_categories.php, look for the function str_rep($row){
    , rename it to function str_rep1($row){

    Paste the following code just above this function.


    function str_rep($row, $quote_style = ENT_QUOTES, $charset = 'UTF-8')
    {
    if (is_array($row)) {
    foreach($row as $key => $value) {
    $row[$key] = htmlspecialchars_deep($value, $quote_style, $charset);
    }
    } elseif (is_string($row)) {
    $row = htmlspecialchars(htmlspecialchars_decode($row, $quote_style), $quote_style, $charset);
    }
    return $row;
    }

    so you end up with :

    function str_rep($row, $quote_style = ENT_QUOTES, $charset = 'UTF-8')
    {
    if (is_array($row)) {
    foreach($row as $key => $value) {
    $row[$key] = htmlspecialchars_deep($value, $quote_style, $charset);
    }
    } elseif (is_string($row)) {
    $row = htmlspecialchars(htmlspecialchars_decode($row, $quote_style), $quote_style, $charset);
    }
    return $row;
    }
    function str_rep1($row){
    $row = str_replace('&', '&', $row);
    $row = str_replace('&', '&', $row);
    $row = str_replace('>', '>', $row);
    $row = str_replace('<', '<', $row);
    return $row;
    }

    This will allow the XML to complete, on removing the WHOLE product name where there is a special character it cant replace.

    eg.. Product name = Penne á Candela Pasta from Naples 500g returns an empty product name because of the á
    So, I ran the get_categories.php, with the replacement function str_rep, went through it, noting all products without a product name, just id.
    eg..<item text=“” id=”p_6102″ im0=”leaf.gif” im1=”leaf.gif” im2=”leaf.gif”/>
    then looked to find the offending character, replacing it using the following function, as I believe, the only replacement that takes place using the original function, is the last one in the order, so I ended up with the following.

    function str_rep1($row, $quote_style = ENT_QUOTES, $charset = 'UTF-8')
    {
    if (is_array($row)) {
    foreach($row as $key => $value) {
    $row[$key] = htmlspecialchars_deep($value, $quote_style, $charset);
    }
    } elseif (is_string($row)) {
    $row = htmlspecialchars(htmlspecialchars_decode($row, $quote_style), $quote_style, $charset);
    }
    return $row;
    }
    function str_rep($row){

    $spec_cs = array('ú', 'î', 'á', 'é', '£'); // These are the only Special Characters I needed to replace!!
    $specialarray=array('ú', 'í', 'á', 'é', '£');
    $row1 = str_replace($spec_cs, $specialarray, $row);

    $row = str_rep1($row1);
    return $row;

    Hope this helps..

    Thanks, I followed the above instructions and it works fine. I did try your last suggestion replacing the function, but all I get is a blank page. Thanks for the help.

  • #122728

    TheLango
    Participant

    @nattack wrote:

    Thanks, I followed the above instructions and it works fine. I did try your last suggestion replacing the function, but all I get is a blank page. Thanks for the help.

    Apologies, I missed the bottom of the code off.. should have read..

    function str_rep1($row, $quote_style = ENT_QUOTES, $charset = 'UTF-8')
    {
    if (is_array($row)) {
    foreach($row as $key => $value) {
    $row[$key] = htmlspecialchars_deep($value, $quote_style, $charset);
    }
    } elseif (is_string($row)) {
    $row = htmlspecialchars(htmlspecialchars_decode($row, $quote_style), $quote_style, $charset);
    }
    return $row;
    }
    function str_rep($row){

    $vowels = array('ú', 'í', 'á', 'é', '£');
    $myarray=array('ú', 'í', 'á', 'é', '£');
    $row1 = str_replace($vowels, $myarray, $row);


    $row = str_rep1($row1);


    return $row;
    }

  • #122730

    soundzgood2
    Participant

    That’s great – thanks TL (another error fixed!)
    Simon

    @thelango wrote:

    @nattack wrote:

    Thanks, I followed the above instructions and it works fine. I did try your last suggestion replacing the function, but all I get is a blank page. Thanks for the help.

    Apologies, I missed the bottom of the code off.. should have read..

    function str_rep1($row, $quote_style = ENT_QUOTES, $charset = 'UTF-8')
    {
    if (is_array($row)) {
    foreach($row as $key => $value) {
    $row[$key] = htmlspecialchars_deep($value, $quote_style, $charset);
    }
    } elseif (is_string($row)) {
    $row = htmlspecialchars(htmlspecialchars_decode($row, $quote_style), $quote_style, $charset);
    }
    return $row;
    }
    function str_rep($row){

    $vowels = array('ú', 'í', 'á', 'é', '£');
    $myarray=array('ú', 'í', 'á', 'é', '£');
    $row1 = str_replace($vowels, $myarray, $row);


    $row = str_rep1($row1);


    return $row;
    }

  • #122729

    TheLango
    Participant

    On the back of this, I have just noticed that when mousing over the comment icon in admin orders, the “HelpTip” breaks also if you have special characters in a product name, so

    I have moved the above function to admin/includes/functions/html_output.php and edited admin/orders.php as follows.

    Find the following around line 620..

                      <img src="images/icons/comment2.gif" onmouseover="showhint('', this, event, '300px'); return false" align="top" border="0">

    and replace with …

    <img src="images/icons/comment2.gif" onmouseover="showhint('', this, event, '300px'); return false" align="top" border="0">

    Also for all interested the 300px is the width of the tooltip box when displaying the order contents, as We have long product names we have increased to 450px, so the names dont wrap.

    NOTE!! you must have the following function in a page that loads constantly.. eg.. admin/includes/functions/html_output.php, admin/includes/functions/general.php etc…

    function str_rep1($row, $quote_style = ENT_QUOTES, $charset = 'UTF-8')
    {
    if (is_array($row)) {
    foreach($row as $key => $value) {
    $row[$key] = htmlspecialchars_deep($value, $quote_style, $charset);
    }
    } elseif (is_string($row)) {
    $row = htmlspecialchars(htmlspecialchars_decode($row, $quote_style), $quote_style, $charset);
    }
    return $row;
    }
    function str_rep($row){

    $vowels = array('ú', 'í', 'á', 'é', '£');
    $myarray=array('ú', 'í', 'á', 'é', '£');
    $row1 = str_replace($vowels, $myarray, $row);


    $row = str_rep1($row1);


    return $row;
    }
  • #122731

    Michael-E
    Participant

    Had same problem…but with b2b version. Found out all I had to do was find the

    /admin/get_categories.php file

    and add:

    $row = str_replace(‘/’, ‘/’, $row);

    right above the

    return $row;

    :mrgreen: — I’m learning — :mrgreen:

  • #122732

    TheLango
    Participant

    Congrats, and good to see someone having a go at solving his/her own problems..
    AND even taking the time to post 😀

    We need to be carful, will almost become a nice, friendly, helpful community again :mrgreen:

  • #122733

    datoad
    Participant

    Hi guys,

    It looks like I need to do the changes as well. But my question is, if I don’t do the changes will the coupon still work on all items? Hence if I don’t need to select certain categories do I even need to make this fix?

    Please see the attached picture, is this how a finished coupon should look? (see red box)

    Thanks,
    datoad

You must be logged in to reply to this topic.

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close