Jump to content

Start tag expected - when it is?!


Haighy

Recommended Posts

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 by Haighy
Link to comment
Share on other sites

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 by Haighy
Link to comment
Share on other sites

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"?>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

[/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 by Haighy
Link to comment
Share on other sites

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 by Ingolme
Link to comment
Share on other sites

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.xD; 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.xD; 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.htmlxD;< /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>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...