I have posted in my other thread as well. I have finally built a module to handle XML data feed.
Feel free to use/modify it to suit your need. See wiki for more details. Wiki:// ANO XML Parser
Unable to load the following language file: /lang.ano_xml_parser.php
I have waited long time for xml_walk as I do a lot of xml stuff. Trying the above, the zip file is missing the lang file. Looking forward to trying it, I have been using php5 which is awesome, and the original magpie parser which handles anything pretty well, but this as a module looks very good.
From my on-line document:
Overview - This plugin will parse a valid remote XML-based file and return entries as EE variables to be used in your EE template. - This parser will also work as a RSS reader but channel information will be omitted. - XML data are cached in database to improve performance. - Cached data can be monitored in Module Control panel. - You should use the W3C tool (XML Validator) to validate your XML data feed. - Within each child node, no identical element name is allowed at the same level. - PHP CURL (Client URL library) is required on web server to run this module. - This light-weight parser may not work with very large or deep-nested XML files. - Feel free to customize this module to suit your needs. I only implement it in the most basic way to deal with my XML project on hand.
So the answer is a unfortunately no. You can add logics in the area where the tag names are constructed by appending like _1, _2 for duplicated names. That should do the trick but do need some development works.
Article at Zend that is good on simplexml and parsing
how would I grab the first? right now it only grabs the last.
example there to get specific items:
// access each <sin>
echo $xml->sin[0] . "\n"; <- first item
echo $xml->sin[1] . "\n";
echo $xml->sin[2] . "\n";
echo $xml->sin[3] . "\n";
echo $xml->sin[4] . "\n";
echo $xml->sin[5] . "\n";
Hey Arnold. Do you (or anyone!) know why I get this:
Warning: curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set in /home/deadfrog/public_html/system/modules/ano_xml_parser/mod.ano_xml_parser.php on line 101
Hey Arnold. Do you (or anyone!) know why I get this: Warning: curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set in /home/deadfrog/public_html/system/modules/ano_xml_parser/mod.ano_xml_parser.php on line 101
Hi Andy,
This is a harmless warning. I don’t recall the exact cause now. I experienced the same issue with a site hosting on EngineHosting. I just muted the error and everything works fine.
@curl_setopt($c, CURLOPT_FOLLOWLOCATION, 1);
Hi,
Thanks for posting this module, it does exactly what I need. The only small issue I have is that if the XML file is not found or the XML is invalid PHP error messages are echo’d to the page, breaking the layout.
Is there an easy way to alter the module to have it fail silently? Sorry I’m not very familiar with PHP.
It would be perfect if it would fail silently or just output a simple error to the page.
Thanks again.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.