|  | 
  Peter - 2007-07-11 01:12:32Hi there.. I'm getting this error message:Warning: key() [function.key]: Passed variable is not an array or object in /home/server/image_gallery_xml.php on line 145
 
 from the following code:
 $xml = new Xml;
 $out = $xml->parse('http://www.mywebsite.com/director/images.php', 'CURL');
 print_r($out);
 
 
 
 I haven't changed the functions in any form.. everything has come straight from this site. Can you please help?
  Ivan Enderlin - 2007-07-11 07:15:38 - In reply to message 1 from PeterIt arrives that we have this error.
 When parser does not parsed correctly the XML file, final array is not "well-formed", so key function returns an error.
 
 Can I see your XML file ? Maybe it's a problem from your XML code (at least, it provided often of code form).
  Benson Lu - 2007-07-30 09:47:38 - In reply to message 2 from Ivan Enderlinhi, i just encountered same problem, here is my xml:
 <BlogLook>
 <BlogID>5</BlogID>
 <URL>http://www.wretch.cc/blog/cwwany</URL>
 <Rank>1</Rank>
 <Index>5560</Index>
 <Percent>100.00</Percent>
 <Hits>118379</Hits>
 <Average>156167</Average>
 <Activity>133</Activity>
 
 </BlogLook>
 
 would you please check this and find a way out? appreciate for your time. thanks.
 
 Benson
  Ivan Enderlin - 2007-07-30 11:58:15 - In reply to message 3 from Benson LuHey Benson,there is no problem with your code.
 
 PHP key function need an array, we're agree about that. And, PHP has a problem with his own XML parser. The parser need a handler tag, it means :
 [code]
 <BlogID>5</BlogID>
 <URL>http://www.wretch.cc/blog/cwwany</URL>
 <Rank>1</Rank>
 <Index>5560</Index>
 <Percent>100.00</Percent>
 <Hits>118379</Hits>
 <Average>156167</Average>
 <Activity>133</Activity>
 [/code]
 
 is not correct. Parser doesn't find any handler tag, and doesn't built array correctly.
 
 So, give him one :
 
 [code]
 <BlogLook>
 <BlogID>5</BlogID>
 <URL>http://www.wretch.cc/blog/cwwany</URL>
 <Rank>1</Rank>
 <Index>5560</Index>
 <Percent>100.00</Percent>
 <Hits>118379</Hits>
 <Average>156167</Average>
 <Activity>133</Activity>
 <BlogLook>
 [/code]
 
 If you renseign directly the source, second parameter will be set to null. If source in is a file, second parameter will be set to 'FILE'. Take care of that. Look example, maybe you'll find some help :)
 
 Do you understand now ? Is your problem resolved ?
  Benson Lu - 2007-07-31 08:21:48 - In reply to message 4 from Ivan EnderlinThank you for helping me. My problem has been solved! This is a quite useful script to me. Thanks again!
 Benson
  Ivan Enderlin - 2007-07-31 12:43:24 - In reply to message 5 from Benson LuYou're welcome ;-)
  Luca Mainieri - 2007-11-27 18:09:46 - In reply to message 6 from Ivan EnderlinHi, I'm experiencing the exact same error.
 Sorry but example and previous posts did not help me to find the problem:
 
 Here's my XML
 
 <?xml version="1.0"?>
 <PUBLICPROFILES>
 <EXPORT-RECORDS>
 <ROW>
 <ARTISTID>477</ARTISTID>
 <ARTISTNAME>Nome artista</ARTISTNAME>
 <ARTISTITLE>il migliore del mondo e sadlkj</ARTISTITLE>
 <ARTISTCATEGORY>Attore comico</ARTISTCATEGORY>
 <ARTISTDESCRIPTION>asf</ARTISTDESCRIPTION>
 <ARTISTUPDATEDON>20071127</ARTISTUPDATEDON>
 <ARTISTIMAGES></ARTISTIMAGES>
 <ARTISTFILES></ARTISTFILES>
 <ARTISTLINK>www.artcalendar.it</ARTISTLINK>
 </ROW>
 </EXPORT-RECORDS>
 </PUBLICPROFILES>
 
 to retrieve the data I'm using the following
 
 $objXml = new Xml;
 $out = $objXml->parse('http://hurrah.artcalendar.it/public/public.xml','CURL');
 print_r($out);
 
  Luca Mainieri - 2007-12-12 07:56:31 - In reply to message 7 from Luca MainieriHi, is there anybody who can give me a help on this?I've followed all exemples and posts, but still getting the same error.
 Is the XML wrong formatted? is a problem with the php version (4.4)?
 
 Any hint on how to solve this error would be greatly appreciated.
 
 Thanks
 
 Luca
 ______
 
 
 Hi,
 I'm experiencing the exact same error.
 Sorry but example and previous posts did not help me to find the problem:
 
 Here's my XML
 
 <?xml version="1.0"?>
 <PUBLICPROFILES>
 <EXPORT-RECORDS>
 <ROW>
 <ARTISTID>477</ARTISTID>
 <ARTISTNAME>Nome artista</ARTISTNAME>
 <ARTISTITLE>il migliore del mondo e sadlkj</ARTISTITLE>
 <ARTISTCATEGORY>Attore comico</ARTISTCATEGORY>
 <ARTISTDESCRIPTION>asf</ARTISTDESCRIPTION>
 <ARTISTUPDATEDON>20071127</ARTISTUPDATEDON>
 <ARTISTIMAGES></ARTISTIMAGES>
 <ARTISTFILES></ARTISTFILES>
 <ARTISTLINK>www.artcalendar.it</ARTISTLINK>
 </ROW>
 </EXPORT-RECORDS>
 </PUBLICPROFILES>
 
 to retrieve the data I'm using the following
 
 $objXml = new Xml;
 $out = $objXml->parse('http://hurrah.artcalendar.it/public/public.xml','CURL');
 print_r($out);
 |