![]() |
XML and simplexml_load_file - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: XML and simplexml_load_file (/showthread.php?tid=6133) |
XML and simplexml_load_file - El Forum - 02-15-2008 [eluser]bapobap[/eluser] Hi all, Quick question, I'm importing an XML file and inserting the data in MySQL. The XML files contains this: Code: <Event Status>2</Event Status> which simple_xml doesn't seem to like, I'm assuming because of the space between Event and Status. Is there anyway to tell it to ignore this, as I'm not using the keys for anything, just the values. The specific error message is: Code: parser error : Specification mandate value for attribute Status XML and simplexml_load_file - El Forum - 02-15-2008 [eluser]Negligence[/eluser] Not sure what this has to do with CI, but XML elements are not to have spaces in their name. Fix your XML and you've fixed your problem. XML and simplexml_load_file - El Forum - 02-15-2008 [eluser]bapobap[/eluser] Nothing really to do with CI, this has to run via CRON so it's just feeding the MySQL db for the nice interface (which is built with CI). Unfortunately I can't fix the XML file, it's provided by a company that has absolutely no interest in fixing any formatting problems in the XML file. I just have to work around it myself. XML and simplexml_load_file - El Forum - 02-15-2008 [eluser]bapobap[/eluser] Also, just to add, I thought about getting the contents of the file into a string, str_replacing these tags to remove the space then saving that as a file but the file is too big (90MB). I can change the settings on the development machine but not on the production server so I can't use that method. XML and simplexml_load_file - El Forum - 02-15-2008 [eluser]Pygon[/eluser] Yeah, simple xml only works with well formatted XML documents. I see alot of manual processing in your future. XML and simplexml_load_file - El Forum - 02-15-2008 [eluser]bapobap[/eluser] Bummer, thanks! XML and simplexml_load_file - El Forum - 03-24-2008 [eluser]nikefido[/eluser] er..check out php.net/simplexml It can deal with spaces and dashes and all that with little problem... http://us.php.net/simplexml See example number 3 |