Closed (fixed)
Project:
Feeds XPath Parser
Version:
6.x-1.8
Component:
Code
Priority:
Minor
Category:
Bug report
Assigned:
Reporter:
Created:
31 Jul 2010 at 12:21 UTC
Updated:
23 Oct 2010 at 20:50 UTC
Jump to comment: Most recent file
Hello;
First of all to the developer of this, great work!
I am using xPathp Parser to parse a weather feed from Environment Canada
http://dd.weatheroffice.gc.ca/citypage_weather/xml/NS/s0000318_e.xml
This feed is odd in comparison to most simple XML, where sometimes if a field does not apply it won't appear in the feed. xPath Parser of course freaks out and won't parse anything. Is there anything that I can put into the query to prevent it from not parsing in this situation?
Any insights would be greatly appreciated.
Thanks;
-Ryan
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | data.osm_.zip | 1.39 KB | gthoele |
Comments
Comment #1
twistor commentedlooking into it, thanks for the sample doc. It helps a lot.
Comment #2
twistor commentedCan you give me an example of your context and queries?
Comment #3
twistor commentedAlso, if you could try using the dev version it solves the missing element issues my making the user provide a context expression first. That's the only way I could find to avoid this issue.
Comment #4
rbrownellHi;
Thanks for your responses. I did try the dev version, but I wasn't exactly sure where to start with the context expression. I am going to give it a stab and let you know what I encounter.
BTW, do you have a paypal donation form? I really would like to contribute some money to the project.
Thanks;
-Ryan
Comment #5
rbrownellThat did it, thanks for your help!
It wouldn't be a bad idea to mention the context expression in the documentation that is being created for this module.
Would I be correct in assuming to pass the NA variable that in CCK the input type be set to text and the default value be "NA", so that when XPath Parser does not fill in a value CCK automatically fills it in?
Thanks;
-Ryan
Comment #6
rbrownellClosing...
Comment #7
rbrownellComment #8
rbrownellComment #9
rbrownellIssue resolved in most recent dev release.
Comment #10
gthoele commentedHello,
i've got a similar issue with nonexisting XML elements. The developer version worked for me as well, but broke around the time version 1.6 was released.
I am using XPath Parser to parse Openstreetmap geodata. The feed i am using is this (see attachment as well):
http://xapi.openstreetmap.org/api/0.6/node[power=generator][bbox=15,47,1...
(its a list of power plants)
My context query is /osm/node and my field querys look like @id or tag[k='operator']/@v.
A characteristic of Openstreetmap feeds is lots and lots of not-always-existing elements, which i want to resolve to an empty field in Drupal. Since 1.6 i'm getting error messages instead "There was an error with your Query"
A very dirty fix for this is (excerpt from FeedsXPathParser.inc from line 82) turning off error checking altogether:
This works for me but is butt-ugly, and it is generating warnings further down in code (at line 111) for each empty element.
My favourite solution would be to use XPath querys that simply return empty strings for missing elements instead of errors. This could in theory be accomplished by enclosing the query in "string()" (which is an official XPath function which returns empty strings for nonexisting elements, perfect!), but PHPs XPath processor doesn't know how to deal with that function, see comment Nr. 4 on this page:
http://de2.php.net/manual/en/simplexmlelement.xpath.php
Hmmm. I can't really suggest a clean solution. Any Ideas?
Gunnar
Comment #11
twistor commentedThe is the problem: depending on the version on libxml used internally, it may return an empty array or FALSE. There's a workaround that I've implemented, I'm committing it to dev since initial tests seem to work properly. Thanks!
http://drupal.org/cvs?commit=431892
Comment #12
gthoele commentedHi Twistor,
i tried the recent devel version and your workaround seems to work very well for parsing Openstreetmap data. Thanks!
Gunnar