We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

ANO XML Parser

Development and Programming

Leslie Camacho's avatar
Leslie Camacho
1,340 posts
16 years ago
Leslie Camacho's avatar Leslie Camacho

Hi all,

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

       
arnoldc's avatar
arnoldc
122 posts
16 years ago
arnoldc's avatar arnoldc
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.

       
bobh's avatar
bobh
145 posts
16 years ago
bobh's avatar bobh

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.

       
arnoldc's avatar
arnoldc
122 posts
16 years ago
arnoldc's avatar arnoldc

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.

       
Squanto's avatar
Squanto
7 posts
16 years ago
Squanto's avatar Squanto

Redacted for my own stupidity!

       
arnoldc's avatar
arnoldc
122 posts
16 years ago
arnoldc's avatar arnoldc
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.

Hi Bob,

I have just updated the parser to v1.1 with three new changes:

  • added limit tag
  • added duplicated element name support
  • added conditional variable

Sample template codes to your xml feed:

{exp:ano_xml_parser:fetch
source='http://ws.audioscrobbler.com/2.0/user/Taggetig/topartists.xml'
refresh='0' parent_tag='topartists' child_tag='artist' limit="10"}
Name: {artist_name}, Ranking: {artist_rank}

URL:: <a href="http://{artist_url}">{artist_url}</a><br>
{if artist_image} image size={artist_image_size}: {artist_image}<br>{/if}
{if artist_image_2}  image size={artist_image_size_2}:{artist_image_2}<br>{/if}
{if artist_image_3} image_size={artist_image_size_3}:{artist_image_3}<br>{/if}
<hr>
{/exp:ano_xml_parser:fetch}

Please download v1.1 in the Wiki area.

       
bobh's avatar
bobh
145 posts
16 years ago
bobh's avatar bobh

arnold, thanks so much, it does everything I wanted it to do now. much appreciated 😊

       
arnoldc's avatar
arnoldc
122 posts
16 years ago
arnoldc's avatar arnoldc
arnold, thanks so much, it does everything I wanted it to do now. much appreciated 😊

Great! I have just moved to the version to the Wiki area.

       
swillia1's avatar
swillia1
11 posts
16 years ago
swillia1's avatar swillia1

Thanks for the reply at Solspace Arnold. Before I get it installed, is this XML too deeply nested to use the module, or do you think it would work?

http://api.oodle.com/api/v2/listings?key=TEST&region=chicago&category=vehicle/car

       
arnoldc's avatar
arnoldc
122 posts
16 years ago
arnoldc's avatar arnoldc
Thanks for the reply at Solspace Arnold. Before I get it installed, is this XML too deeply nested to use the module, or do you think it would work? http://api.oodle.com/api/v2/listings?key=TEST®ion=chicago&category=vehicle/car

Just tested it and seem to work fine with the link.

Sample Code

{exp:ano_xml_parser:fetch
source='http://api.oodle.com/api/v2/listings?key=TEST®ion=chicago&category=vehicle/car'
refresh='0' parent_tag='listings' child_tag='element' limit="10"}
ID:{element_id}

body:{element_body}

location name: {element_location_name}

image element 1 source:{element_images_element_src}<br>
image element 2 source:{element_images_element_src_2}<br>
price:{element_attributes_price}<br>
<hr>
{/exp:ano_xml_parser:fetch}
       
swillia1's avatar
swillia1
11 posts
16 years ago
swillia1's avatar swillia1

I uploaded the module, but get the following error when I click on the modules tab:

Unable to load the following language file:

lang.ano_xml_parser_1_1.php

The language file that was with the ZIP was lang.ano_xml_parser.php, so is this an error with the naming of the language file or in the code of the module?

Sorry for the questions but still a bit of an EE newb.

       
Ingmar Greil's avatar
Ingmar Greil
29,243 posts
16 years ago
Ingmar Greil's avatar Ingmar Greil

You need to put the language file in the right directory, ie /system/languages/english.

       
swillia1's avatar
swillia1
11 posts
16 years ago
swillia1's avatar swillia1

Finally solved it:

You need to put the language file in the right directory, ie /system/languages/english.

Moved the language file, but still getting the same error:

Unable to load the following language file:

/lang.ano_xml_parser_1_1.php


The ZIP file had the ‘_1_1’ appended on the end for the version info, but that needed to be removed to have the file names process correctly. Just a heads up for anyone else that is installing this module. Now to see if we can get it to work…

       
arnoldc's avatar
arnoldc
122 posts
16 years ago
arnoldc's avatar arnoldc

Sorry for missing the obvious. i have repacked the files so it makes more logical sense for installation and the link has been updated in the Wiki area. Nothing has changed so you don’t need to re-download it.

       
david.brunelle's avatar
david.brunelle
4 posts
16 years ago
david.brunelle's avatar david.brunelle

I discovered your module and it’s JUST what I need. I have one problem, and I’m not sure if this is something I’m overlooking or if it’s something the module doesn’t support.

Here’s an example of the xml data I’m trying to parse:

<item>
    <Description>COSBY SHOW: SEASON 4, THE Video</Description>
    <Title>COSBY SHOW: SEASON 4, THE</Title>
    <Rating>Not Rated</Rating>
    <Genre>Comedy</Genre>
</item>

I’m trying to filter out anything that’s NOT rated PG or G. I tried this conditional:

{if item_Rating == "PG"}{item_Title}{/if}

That type of conditional doesn’t seem to work. Is it possible to do more with this module than just check for the existence of an element?

Thanks for the help and the great module!

       
1 2 3 4 Last

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.