#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    26
    Rep Power
    0

    XmlParseEntityRef: no name


    I am getting this error. I know, I know, its ampersand crap, as referenced in

    http://stackoverflow.com/questions/7604436/xmlparseentityref-no-name-warnings-while-loading-xml-into-a-php-file

    And

    http://stackoverflow.com/questions/11620932/simplexml-load-file-problems

    But implementing the fixes doesnt help. IT is still breaking.

    Code

    PHP Code:

    <?php 



    $url_value
    ="http://webservices.theshootingwarehouse.com/smart/inventory.asmx/DailyItemUpdate?CustomerNumber=15753&UserName=15753&Password=75035&LastUpdate=06/11/2013&LastItem=0&Source=15753";
    $url_to_work_on=file_get_contents($url_value);//get the data
    $url_to_work_on=preg_replace('/&(?!#?[a-z0-9]+;)/''&amp;'$url_to_work_on);
    $wrapping_xml=simplexml_load_string($url_to_work_on);//clean it up
    $final_data_to_parse=simplexml_load_string(html_entity_decode($wrapping_xml));


    Print_r($url_to_work_on);



    $my_var=$final_data_to_parse->Table[1]->ITEMNO;  //THIS GENERATES NON OBJECT
    Print_r($my_var);
    ?>
    Intentionally leaving out of php tag, b/c tagging weirds it out. Please see that this line

    $url_to_work_on=preg_replace('/&(?!#?[a-z0-9]+/', '&amp;', $url_to_work_on);

    should have 'AMBERSAND AMP' as the middle argument, but the forum gets wierded out and jsut replaces with an ampersand
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    26
    Rep Power
    0
    ugh..still no luck
  4. #3
  5. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    Hi,

    remove the html_entity_decode(). The XML parser already has decoded all entities the moment it parsed the file. You should use CDATA, though, to prevent the parser from drowning in that sea of entities.

    I have no idea why you'd wanna put a literal XML document into another XML document, but I guess that's how modern webservices work...
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    26
    Rep Power
    0
    Thanks! I finally caught that last night! Ill check out CDATA . Thanks again!

IMN logo majestic logo threadwatch logo seochat tools logo