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

aimelise's avatar
aimelise
31 posts
15 years ago
aimelise's avatar aimelise

I’m wondering if I can get {if no_results} to work inside a conditional. My XML File looks like this.

I’ve got to parse PHP before EE b/c a _GET controls the “ym” variable and determines what XML gets rendered.

My code:

{if event_index !=0 AND event_index!=3}

   {if no_results}
        Sorry, there are no results to display.
   {/if}

{/if}

I've also tried this other conditional (below) and its not working:

{if event_index !=0 AND event_index!=3}

   {if event_title == ""}
        Sorry, there are no results to display.
   {/if}

{/if}

Here's a snippet of that XML file here:

*****

<?xml version="1.0" encoding="ISO-8859-1"?> 
<events> 

<event>
    <date>FRIDAY 5/28 - SATURDAY 6/5</date>
    <time></time>
    <title>HS Semester 2 Final Assessments</title>
    <link>http://www.google.com/calendar/event?eid=NnA1cmJybHBmbjNqMm1kbjc3cXF2MzcyZ28gcjE3bWo5M3NydGxlbWx2N29tOXFjM3A3dG9AZw</link>
    <location>GSIS Campus</location>
    <description></description>
    <index>3</index>    
</event>

<event>
    <date>WEDNESDAY 6/2</date>
    <time>05:00 PM - 07:00 PM</time>
    <title>ES End of Year Assembly & Concert</title>
    <link>http://www.google.com/calendar/event?eid=ZXZjYTYwajBhdWV1N3BwbnBwamc4MnA5NmsgMjJ0N2RuajJhbWExZThvcThtdWZmZnR1Mm9AZw</link>
    <location>GSIS Auditorium</location>
    <description></description>
    <index>0</index>    
</event>

</events>

I would to display a message that nothing is available to be displayed. Wondering why its not working. I hope my explanation isn’t too confusing.

       
arnoldc's avatar
arnoldc
122 posts
15 years ago
arnoldc's avatar arnoldc
I’m finding that conditionals just aren’t working.

A quick glaze may be you are trying to nest another module within the module. I strip out your other module and it works.

{exp:ano_xml_parser:fetch source='http://api.smugmug.com/hack/feed.mg?Type=gallery&Data=10145677_gXk2L&format=atom03&ImageCount=100&Sandboxed=1' refresh='0' parent_tag='feed' child_tag='entry' limit='999'}    
{if entry_title=="video"}
***VIDEO***<br>
video source={entry_id}<br>
title={entry_title}<br>
{if:else}
***IMAGE***<br>
image source={entry_id}<br>
title={entry_title}<br>
{/if}
{/exp:ano_xml_parser:fetch}
       
arnoldc's avatar
arnoldc
122 posts
15 years ago
arnoldc's avatar arnoldc
I’m wondering if I can get {if no_results} to work inside a conditional. My XML File looks like this. I’ve got to parse PHP before EE b/c a _GET controls the “ym” variable and determines what XML gets rendered. My code:
{if event_index !=0 AND event_index!=3}

   {if no_results}
        Sorry, there are no results to display.
   {/if}

{/if}

I've also tried this other conditional (below) and its not working:

{if event_index !=0 AND event_index!=3}

   {if event_title == ""}
        Sorry, there are no results to display.
   {/if}

{/if}
**** I would to display a message that nothing is available to be displayed. Wondering why its not working. I hope my explanation isn’t too confusing.

Not sure if I intrepret your question correctly but if you are simply trying to display a message when there is no data in your feed, the following code should do the trick:

{exp:ano_xml_parser:fetch source='http://localhost/sample3.xml' refresh='0' parent_tag='events' child_tag='event' limit='999'} 
{if no_results}
   Sorry, there are no results to display.<br>
{/if}
Event index: {event_index}<br>
Event date: {event_date}<br>
Event time: {event_time}<br>
Event title: {event_title}<br>
<hr>
{/exp:ano_xml_parser:fetch}

The {if no_results} is a special condition that will only get executed once when there is no data in your feed.

       
bsjosten's avatar
bsjosten
100 posts
15 years ago
bsjosten's avatar bsjosten

Hi,

I’m trying to use an xml feed that is gzipped. I get no results.

Can I assume this is because it is compressed? Is there a solution?

Here’s the feed:

http://xmltv.tvsajten.com/xmltv/golf.viasat.se_2009-12-08.xml.gz

Thanks,

/Bo

       
arnoldc's avatar
arnoldc
122 posts
15 years ago
arnoldc's avatar arnoldc
Hi, I’m trying to use an xml feed that is gzipped. I get no results. Can I assume this is because it is compressed? Is there a solution? Here’s the feed: http://xmltv.tvsajten.com/xmltv/golf.viasat.se_2009-12-08.xml.gz Thanks, /Bo

It won’t work for the obvious reason as the file is compressed. If it is a static file, you may unzip it and place it somewhere on the net and take that feed instead.

Or you may try to see if there is any other EE plugin to unzip the file first….

       
AJP's avatar
AJP
311 posts
15 years ago
AJP's avatar AJP

I’m having some issues pulling in weather forecast and current conditions data from weatherunderground.com XML feeds are pulled in (as verified by inserting a print_r() after the xml call, but I don’t know what format to do.

Current conditions data doesn’t have children, and is a “static” feed. The forecast (5 day) can be done. The feeds are the following. Current Conditions: http://api.wunderground.com/auto/wui/geo/WXCurrentObXML/index.xml?query=GRR

Forecast: http://api.wunderground.com/auto/wui/geo/ForecastXML/index.xml?query=GRR

Weather alerts: http://api.wunderground.com/auto/wui/geo/AlertsXML/index.xml?query=GRR

Help? Thanks!

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

You need to use the special keyword “no_root” in your parent tag.

See the following sample and it works for the first feed. I haven’t tried the other feeds but let me know if you run into issues in a different way.

<h1>W3C Sample XML Test</h1>

{exp:ano_xml_parser:fetch source=' http://api.wunderground.com/auto/wui/geo/WXCurrentObXML/index.xml?query=GRR' refresh="0" parent_tag="_no_root_" child_tag="current_observation" limit="1"}
Credit:{current_observation_credit}<br>
City:{current_observation_display_location_full}<br>
Observation location:{current_observation_observation_location_full}
<hr>
{/exp:ano_xml_parser:fetch}
       
arnoldc's avatar
arnoldc
122 posts
15 years ago
arnoldc's avatar arnoldc
Can I get a {count} variable? So I can set alternating styles and such? or a switch variable? Also an offset? So I could skip the first entry through the loop?

This is no built-in support but you can always mix up with PHP codes to go beyond what this module has to offer.

Make sure you enable PHP and set the PHP parsing stage to Output. See the following sample to illustrate the PHP method. May be one day I will incorporate these features into the module but until then….

<h1>W3C XML Alternate Color Test with PHP Codes</h1>
<? 
/* PHP initialization */
$count=0; 
$offset=0;
?>
Alternate row color and skip first entry.<br><br>
{exp:ano_xml_parser:fetch source='http://www.w3schools.com/xml/simple.xml' refresh="0" parent_tag="breakfast_menu" child_tag="food"}
<? 
/* PHP section within ANO XML parser loop, make sure PHP is enabled and PHP Parsing Stage is set to OUTPUT in the template */ 
$offset++;
$count++;
if ($offset>1) {
  if ($count%2==0) {
    echo "Offset #".$offset.": {food_name} has {food_calories} calories.";
  }
  else {
    echo "Offset #".$offset.": {food_name} has {food_calories} calories.";
  }

  echo "<hr>";
}
?>
{/exp:ano_xml_parser:fetch}
<?
  echo "Total food count:".$count."<br>";
?>
       
AJP's avatar
AJP
311 posts
15 years ago
AJP's avatar AJP

Thanks so much for the help. This is perfect.

       
NKT com's avatar
NKT com
124 posts
15 years ago
NKT com's avatar NKT com

I really can’t figure out why this works…

{exp:ano_xml_parser:fetch source='http://gallery.kadampa.org/hack/feed.mg?Type=gallery&Data=9265123_H8FTE&format=atom10&Sandboxed=1' refresh='0' parent_tag='feed' child_tag='entry' limit='999' }    

<image source="{entry_id}" >

{/exp:ano_xml_parser:fetch}

But this doesn’t…

{exp:ano_xml_parser:fetch source='http://gallery.kadampa.org/hack/feed.mg?Type=userkeyword&NickName=kadampa&Data=2010&format=atom10&Sandboxed=1&Size=Small' refresh='0' parent_tag='feed' child_tag='entry' limit='999' }    

<image source="{entry_id}" >

{/exp:ano_xml_parser:fetch}

The two feeds output the same XML from what i can see. http://gallery.kadampa.org/hack/feed.mg?Type=gallery&Data=9265123_H8FTE&format=atom10&Sandboxed=1

http://gallery.kadampa.org/hack/feed.mg?Type=userkeyword&NickName=kadampa&Data=2010&format=atom10&Sandboxed=1&Size=Small

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

Hmm, I didn’t receive any email notification for whatever reason regarding this last question.

Anyway, I just tried and both work for me. Your HTML tag is incorrect. It should be

{entry_id}
       
ErwinVanLun's avatar
ErwinVanLun
235 posts
15 years ago
ErwinVanLun's avatar ErwinVanLun

this seems to be a great plugin. But I need it for EE 2.0. Any update on the planning?

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

Sorry, no 2.0 roadmap. I don’t use EE often these days. Perhap an experienced EE developer may want to take over this project for 2.0…..

       
ChrisR1776's avatar
ChrisR1776
11 posts
15 years ago
ChrisR1776's avatar ChrisR1776

I’m not sure with those two feeds, but there is a bug (or perhaps poor error trapping) in parse_into_struct in system/core/core.xmlparser.php which, I think, ANO XML Parser uses. I was pulling in an XML feed and suddenly it stopped working. Obviously the feed coming in should be correct, but often not if it is coming from a third party.

After checking each item, and finding one particular item that had a PART of line that looked like this: March ” or the state will

Now, that looks fine to the naked eye. But I looked it it in a text editor and found an un-escaped character (hex 1B) - ESCAPE in fact. Deleting the character or encoding it like this fixes it: March \0x1B” or the state will

So, perhaps there are un-encoded characters in the feed?

I think either ANO XML Parser should check for un-escaped characters prior to passing to parse_into_struct or parse_into_struct should check for it in whatever feed it gets.

Something to check.

I really can’t figure out why this works…
{exp:ano_xml_parser:fetch source='http://gallery.kadampa.org/hack/feed.mg?Type=gallery&Data=9265123_H8FTE&format=atom10&Sandboxed=1' refresh='0' parent_tag='feed' child_tag='entry' limit='999' }    

<image source="{entry_id}" >

{/exp:ano_xml_parser:fetch}
But this doesn’t…
{exp:ano_xml_parser:fetch source='http://gallery.kadampa.org/hack/feed.mg?Type=userkeyword&NickName=kadampa&Data=2010&format=atom10&Sandboxed=1&Size=Small' refresh='0' parent_tag='feed' child_tag='entry' limit='999' }    

<image source="{entry_id}" >

{/exp:ano_xml_parser:fetch}
The two feeds output the same XML from what i can see. http://gallery.kadampa.org/hack/feed.mg?Type=gallery&Data=9265123_H8FTE&format=atom10&Sandboxed=1 http://gallery.kadampa.org/hack/feed.mg?Type=userkeyword&NickName=kadampa&Data=2010&format=atom10&Sandboxed=1&Size=Small
       
ChrisR1776's avatar
ChrisR1776
11 posts
15 years ago
ChrisR1776's avatar ChrisR1776

Hi, Just to follow up with my solution, what I ended up doing in my cron job is:

  1. wget-ing the file into thexml2.xml

  2. then: tr -cd ‘\11\12\40-\176’ < thexml2.xml > thexml.xml

This strips the non-printing control characters (except 11 and 12 in octal - LF and tab) from the file and puts it in thexml.xml which is what I use ANO XML to read.

Since it appears there will be no 2.0 version, I may have to switch. 😉

Might not suit everyone, but thought I’d follow up in case someone else saw the same issue.

       
First 4 5 6 7 8

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.