1 of 6
1
ANO XML Parser
Posted: 27 May 2008 12:50 PM   [ Ignore ]  
Lab Assistant
Avatar
RankRank
Total Posts:  148
Joined  03-06-2008

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

Profile
 
 
Posted: 27 May 2008 04:01 PM   [ Ignore ]   [ # 1 ]  
Lab Technician
RankRankRankRank
Total Posts:  1084
Joined  03-25-2005

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.

 Signature 

BKDesign Solutions - Learn XHTML and use   Web Standards to build accessible websites that validate

Profile
 
 
Posted: 27 May 2008 04:31 PM   [ Ignore ]   [ # 2 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  148
Joined  03-06-2008

Fixed.  Please re-load the new zip file.

Btw, anyone knows if there is a way to delete the old zip file in Wiki area?

Profile
 
 
Posted: 27 May 2008 04:48 PM   [ Ignore ]   [ # 3 ]  
Lab Technician
RankRankRankRank
Total Posts:  1084
Joined  03-25-2005

Wow that was fast, installed ok, looks good.
Can it do: media:content url?
Note to self: try it then ask:
Media: {item_media:content_url}

Works!!!!
This is beyond awesome that it does media namespace and enclosure tags.

Is there a limit tag?

Thank you!

 Signature 

BKDesign Solutions - Learn XHTML and use   Web Standards to build accessible websites that validate

Profile
 
 
Posted: 27 May 2008 06:08 PM   [ Ignore ]   [ # 4 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  148
Joined  03-06-2008

Sorry, no limit or the ususal EE parameters.  If you dig PHP, you should have no problem to modify the file to suit your needs.

Profile
 
 
Posted: 09 July 2008 02:14 PM   [ Ignore ]   [ # 5 ]  
Summer Student
Total Posts:  20
Joined  08-02-2007

Hey, any way in your plugin to grab the first item out of a match so for example I go entry_link_href and there are multiple tags like this:

<entry>

<link href=”“>
<link href=”“>
<link href=”“>

</entry>

how would I grab the first? right now it only grabs the last.

Profile
 
 
Posted: 09 July 2008 02:41 PM   [ Ignore ]   [ # 6 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  148
Joined  03-06-2008

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.

Profile
 
 
Posted: 09 July 2008 03:26 PM   [ Ignore ]   [ # 7 ]  
Summer Student
Total Posts:  20
Joined  08-02-2007

Ugh that really blows.  The plugin does exactly what i want but I have no control over the XML file.  I’m using Gdata as a service and all of their xml files have identical element names at the same level.

Can anyone suggest a different plugin?

Profile
 
 
Posted: 10 July 2008 09:23 AM   [ Ignore ]   [ # 8 ]  
Lab Technician
RankRankRankRank
Total Posts:  1084
Joined  03-25-2005

Two options, not plugins but work, the Sofee XML Parser

or if you have php5 use SimpleXML, both will do as wanted/

 Signature 

BKDesign Solutions - Learn XHTML and use   Web Standards to build accessible websites that validate

Profile
 
 
Posted: 10 July 2008 09:27 AM   [ Ignore ]   [ # 9 ]  
Summer Student
Total Posts:  20
Joined  08-02-2007

Thanks Bruce, i’ll look into it.

Profile
 
 
Posted: 10 July 2008 10:09 AM   [ Ignore ]   [ # 10 ]  
Lab Technician
RankRankRankRank
Total Posts:  1084
Joined  03-25-2005

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";
 Signature 

BKDesign Solutions - Learn XHTML and use   Web Standards to build accessible websites that validate

Profile
 
 
Posted: 29 August 2008 02:50 PM   [ Ignore ]   [ # 11 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1130
Joined  02-15-2008

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

 Signature 

Andy Harris | Pepper Digital | Malvern, UK | Twitter | New to ExpressionEngine? Start here!

Profile
 
 
Posted: 29 August 2008 03:07 PM   [ Ignore ]   [ # 12 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  148
Joined  03-06-2008
Andy Harris - 29 August 2008 02:50 PM

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);
Profile
 
 
Posted: 29 August 2008 03:31 PM   [ Ignore ]   [ # 13 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1130
Joined  02-15-2008

Ahh, so I’m only seeing that because I’m logged in as SuperAdmin I presume. That’s fine by me!

Thanks for the reply.

 Signature 

Andy Harris | Pepper Digital | Malvern, UK | Twitter | New to ExpressionEngine? Start here!

Profile
 
 
Posted: 27 October 2008 12:46 PM   [ Ignore ]   [ # 14 ]  
Summer Student
Total Posts:  1
Joined  10-27-2008

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.

Profile
 
 
Posted: 27 October 2008 01:51 PM   [ Ignore ]   [ # 15 ]  
Administrator
Avatar
RankRankRankRankRank
Total Posts:  2961
Joined  05-17-2002

Hi all,

I split this into a new thread so its in the proper forum.

 Signature 
Profile
MSG
 
 
Posted: 28 October 2008 12:00 PM   [ Ignore ]   [ # 16 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  148
Joined  03-06-2008
bg2k - 27 October 2008 12:46 PM

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.

Hi bg2K,
Don’t you want to see errors if something goes wrong with the templates and address the template codes instead?

In any case, if you need this approach, you may add this line to the first line of mod.ano_xml_parser.php to suppress all PHP errors on this page:

error_reporting(0);

Cheers.

Profile
 
 
Posted: 22 December 2008 02:54 PM   [ Ignore ]   [ # 17 ]  
Lab Assistant
RankRank
Total Posts:  275
Joined  01-20-2006

hi arnold, thanks for this module, it’s exactly what I was looking for to grab my Last.fm xml feeds. I have a question if you don’t mind:

How do I check if a tag has content? I’m pulling an artist thumbnail and only want to display it if it exists. A standard {if image !=”“} doesn’t work because an ‘empty’ tag

<image size="small"/>

takes on the variable of the previous non-empty tag. Have a look at this page for a live example.

 Signature 

buro taggetig: web design & event photography from Belgium.  |  Follow me on Twitter

Profile
 
 
Posted: 24 December 2008 08:01 PM   [ Ignore ]   [ # 18 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  148
Joined  03-06-2008

Hi Bob,

Yes, this module is very basic and doesn’t implement some of the EE tags that you would usually see in first-party modules.  Conditional case is not implemented.

Profile
 
 
   
1 of 6
1
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1743, on December 02, 2009 03:47 PM
Total Registered Members: 120547 Total Logged-in Users: 60
Total Topics: 126600 Total Anonymous Users: 40
Total Replies: 665564 Total Guests: 356
Total Posts: 792164    
Members ( View Memberlist )
Newest Members:  ClarkKentBaoHeredamferDr.JohnRamin.Hossainikreesmheatbluemonstasweeper240andrew n