Haighy 0 Posted December 28, 2012 Report Share Posted December 28, 2012 (edited) Hi All I have a bizzar issue which is driving me nuts. I was running a php server on my pc to test my code with no issues - now moved it to the host server and get this issue when try to parse xml: Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 1: parser error : Start tag expected, '<' not found in /websites/123reg/LinuxPackage22/tr/ad/in/tradingbay.co/public_html/Lib/Functions.php on line 154 here is my code: $TDurl = "http://api.tradedoubler.com".$Version.$module.$Format.$TDParams.$Token;print $TDurl;$TDResponse = @file_get_contents($TDurl);$TDParsed_Xml = simplexml_load_string($TDResponse); Edited December 28, 2012 by Haighy Quote Link to post Share on other sites
Haighy 0 Posted December 28, 2012 Author Report Share Posted December 28, 2012 (edited) i also ran $TDurl in IE <?xml version="1.0"?>-<voucherList>-<voucher><id>9142</id><programId>898</programId><programName>Tesco.com</programName><code>XMASTREAT</code><updateDate>1355245444457</updateDate><startDate>1355180400000</startDate><endDate>1356994799999</endDate><title>15% off F&F Limited Edition</title><shortDescription>15% off F&F Limited Edition collection</shortDescription><description>15% off F&F Limited Edition collection</description><voucherTypeId>1</voucherTypeId><defaultTrackUri>http://clk.tradedoubler.com/click?a(2075091)p(898)ttid(13)url(http://www.clothingattesco.com/)</defaultTrackUri><siteSpecific>false</siteSpecific><landingUrl>http://www.clothingattesco.com/</landingUrl></voucher> Edited December 28, 2012 by Haighy Quote Link to post Share on other sites
Ingolme 1,022 Posted December 28, 2012 Report Share Posted December 28, 2012 Have you checked that $TDResponse has the value you expected it to have? Quote Link to post Share on other sites
Haighy 0 Posted December 28, 2012 Author Report Share Posted December 28, 2012 if i do print $TDResponse - no xml structure is shown - is that expected? never checked before Quote Link to post Share on other sites
Haighy 0 Posted December 28, 2012 Author Report Share Posted December 28, 2012 i have compared the $TDResponse between my test pc and the web host and both look identical - therefore am still puzzled why one works and not the other. could be something to do with the xml header? <?xml version="1.0"?> i have similar xml structures which are correctly parsed (using the same technic) but have a slightly different xml header?xml version="1.0" encoding="UTF-8"?> Quote Link to post Share on other sites
Haighy 0 Posted December 29, 2012 Author Report Share Posted December 29, 2012 the more i read about this, it must be something to do with the decoding. I dont want to convert to JSON at this point. Does anyone have any ideas? Quote Link to post Share on other sites
Ingolme 1,022 Posted December 29, 2012 Report Share Posted December 29, 2012 If $TDResponse is empty then there's the problem. You're not getting data. I recommend removing the @ error suppressing operator so you can see why you're getting the wrong data. Quote Link to post Share on other sites
Haighy 0 Posted December 29, 2012 Author Report Share Posted December 29, 2012 I do get data so that's what is confusing me. It seems that the XML parser can't interpret it though Quote Link to post Share on other sites
Ingolme 1,022 Posted December 29, 2012 Report Share Posted December 29, 2012 If you show the value that's in $TDResponse we can figure out what the problem is. Quote Link to post Share on other sites
Haighy 0 Posted December 30, 2012 Author Report Share Posted December 30, 2012 (edited) [/code] ok here is everything url: http://api.tradedoubler.com/1.0/vouchers.XML;voucherTypeId=1?dateOutputFormat=iso8601?token=248487FBCA39B156B569D8F698C83FF27503CE8F sample from print $TDResponse Tesco.comXMASTREAT13552454444571355180400000135699479999915% off F&F Limited Edition collection15% off F&F Limited Edition collection1http://clk.tradedoubler.com/click?a(2075091)p(898)ttid(13)url(http://www.clothingattesco.com/)falsehttp://www.clothingattesco.com/293718710hmvWQ2013464115928101346364000000135699479999920% off selected pre-orders20% off when yo 3ff u pre-order any one of the listed titles1http://clk.tradedoubler.com/click?a(2075091)p(18710)ttid(13)url(http://hmv.com/hmvwe...-1&pPageID=5701)falsehttp://hmv.com/hmvweb/navigate.do?ctx=1000;-1;-1;-1;-1&ctx=-1;5;-1;-1;-1&pPageID=5701293618710hmvPE2513464115474881346364000000135699479999925% off selected chart CD's25% off selected chart CD's enter code PE25 at checkout1http://clk.tradedoubler.com/click?a(2075091)p(18710)ttid(13)url(http://hmv.com/hmvwe...ch.do?ctx=1000; 3ff -1;-1;-1 Edited December 30, 2012 by Haighy Quote Link to post Share on other sites
Haighy 0 Posted December 30, 2012 Author Report Share Posted December 30, 2012 i have noticed that -1;-1;-1 and 3ff appears regularly - is this decoded xml elements? Quote Link to post Share on other sites
Haighy 0 Posted January 3, 2013 Author Report Share Posted January 3, 2013 Bumping this up as I really need the help here Quote Link to post Share on other sites
Ingolme 1,022 Posted January 4, 2013 Report Share Posted January 4, 2013 (edited) The sample you're showing from TDResponse doesn't look at all like XML, it's not a surprise that the parser doesn't like it. Actually, it sounds like you're not looking at its actual value. Use htmlspecialchars() to see its real content: echo htmlspecialchars($TDResponse); Edited January 4, 2013 by Ingolme Quote Link to post Share on other sites
Haighy 0 Posted January 6, 2013 Author Report Share Posted January 6, 2013 using htmlspecialchars: <voucherList><voucher><id>9706</id><programId>898</programId><programName>Tesco.com</programName><code>TD-PRGM</code><updateDate>1356965680759</updateDate><startDate>1356908400000</startDate><endDate>1357513199999</endDate><title>5 off £30 on any Pre Order Games</title><shortDescription>5 off £30 on any Pre Order Games until 06.01.13 using code TD - PRGM (Offer ends 06.01.13. Excludes </shortDescription><description>5 off £30 on any Pre Order Games until 06.01.13 using code TD - PRGM (Offer ends 06.01.13. Excludes sellers)</description><voucherTypeId>1</voucherTypeId><defaultTrackUri>http://clk.tradedoubler.com/click?a(2075091)p(898)ttid(13)url(http://www.tesco.com/direct/gaming/pre-orders-games/cat15940025.cat?icid=ents_main_slot3 )</defaultTrackUri><siteSpecific>false</siteSpecific><landingUrl>http://www.tesco.com/direct/gaming/pre-orders-games/cat15940025.cat?icid=ents_main_slot3 </landingUrl></voucher><voucher><id>8255</id><programId>122698</programId><programName>Mothercare</programName><code>E4HD</code 3ff>< updateDate>1353600101304</updateDate><startDate>1353538800000</startDate><endDate>1369259999999</endDate><title>Deal's Week - Maclaren Techno XT</title><shortDescription>Deal of the Week - Maclaren Techno XT </shortDescription><description>This offer is valid on selected lines only (U0544, U1308, U1309, U3060, U0530), whilst stocks last. This offer cannot be used in conjunction with any offer/voucher code. Offer ends Monday 26th November 2012</description><voucherTypeId>1</voucherTypeId><defaultTrackUri>http://clk.tradedoubler.com/click?a(2075091)p(122698)ttid(13)url(http://www.mothercare.com/Maclaren-Techno-XT-Stroller---2012/LU1308,default,pd.html )</defaultTrackUri><siteSpecific>false</siteSpecific><landingUrl>http://www.mothercare.com/Maclaren-Techno-XT-Stroller---2012/LU1308,default,pd.html </landingUrl></voucher><voucher><id>2691</id><programId>2973</programId><programName>Lensway</programName><code>NEWLWC</code><updateDate>1345842074436</updateDate><startDate>1345759200000</startDate><endDate>1 3fe 361746799999</endDate><title>12% off Contacts+Free Delivery</title><shortDescription>New Customers get 12% off plus free Delivery for their first contact lens order from LensWay.co.uk</shortDescription><description>**New Customers** get 12% off plus free Delivery for their first contact lens order from LensWay.co.uk.; http://www.lensway.co.uk/contact-lenses</description><voucherTypeId>1</voucherTypeId><defaultTrackUri>http://clk.tradedoubler.com/click?a(2075091)p(2973)ttid(13)url(http://www.lensway.co.uk/contact-lenses)</defaultTrackUri><siteSpecific>false</siteSpecific><landingUrl>http://www.lensway.co.uk/contact-lenses</landingUrl></voucher><voucher><id>2688</id><programId>2973</programId><programName>Lensway</programName><code>RAYBAN</code><updateDate>1345841667876</updateDate><startDate>1345759200000</startDate><endDate>1361746799999</endDate><title> Complete Ray Ban Glasses £79</title><shortDescription>Starting at only £79 shop over 80 styles of Ray Ban glasses. Lenses & delivery included.</ 3fb shortDescription><description>Starting at only £79 shop over 80 styles of Ray Ban glasses. Lenses & delivery included.; Shop Ray Ban Glasses: http://www.lensway.co.uk/glasses/brands/ray-ban/cRayBanFrames-p1.html'>http://www.lensway.co.uk/glasses/brands/ray-ban/cRayBanFrames-p1.html;< /description><voucherTypeId>1</voucherTypeId><defaultTrackUri>http://clk.tradedoubler.com/click?a(2075091)p(2973)ttid(13)url(http://www.lensway.co.uk/glasses/brands/ray-ban/cRayBanFrames-p1.html)</defaultTrackUri><siteSpecific>false</siteSpecific><landingUrl>http://www.lensway.co.uk/glasses/brands/ray-ban/cRayBanFrames-p1.html</landingUrl></voucher><voucher><id>657</id><programId>81570</programId><programName>Microsoft Store UK</programName><code>WINDOWS35OFF</code><updateDate>1338298986356</updateDate><startDate>1338242400000</startDate><endDate>1369864799999</endDate><title>35% OFF Windows7</title><shortDescription>Promo code enabling 35% off all Windows 7 products.</shortDescription><description>Promo code enabling 35% off all Windows 7 products.</description><voucherTypeId>1</ a7 voucherTypeId><defaultTrackUri>http://clk.tradedoubler.com/click?a(2075091)p(81570)ttid(13)</defaultTrackUri><siteSpecific>false</siteSpecific></voucher></voucherList> Quote Link to post Share on other sites
boen_robot 107 Posted January 6, 2013 Report Share Posted January 6, 2013 Here is the first time where the problem starts: < updateDate>1353600101304</updateDate> You can see the start tag starts with a space. That's not a valid XML. Whoever is in charge of generating the XML at api.tradedoubler.com needs to fix that, and you should contact them.It's possible that it previously worked on your PC server either because the point where problem with the other end was introduced, coincides with your migration OR (more likely) because your PC server's XML parser was different from your host one, and your PC one somehow recovered from that error. Quote Link to post Share on other sites
Haighy 0 Posted January 6, 2013 Author Report Share Posted January 6, 2013 Hi XSLT S I dont think it is that - please check out the source xmlhttp://api.tradedoubler.com/1.0/vouchers.XML;voucherTypeId=1?dateOutputFormat=iso8601?token=248487FBCA39B156B569D8F698C83FF27503CE8F looks ok to me Quote Link to post Share on other sites
Haighy 0 Posted January 6, 2013 Author Report Share Posted January 6, 2013 ......or could it be my IE interpreting it better than my host server because i see </ a7 voucherTypeId> when i do a print as mentioned Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.