Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I've followed the instructions over and over, but I can't get this to work. Nothing is showing up the same way as the examples because all of the examples are for Drupal 6. Has anyone been able to get this to work in one of the 7.x versions?
One point of confusion is where do I put the feed processor node tags?
Example:
context: //item
title: title
body: description
url: src/@url
field_salary: salary/[@ccy="usd"]
I'm not seeing anywhere to put these tags.
If anyone can help, that would be great.
Comments
Comment #1
jasonglisson CreditAttribution: jasonglisson commentedComment #2
F.G CreditAttribution: F.G commentedAre you talking about this example :
http://drupal.org/node/919448
I'm in the same case ! first install of this module and D7 !
Regards,
F.
Comment #3
aenw CreditAttribution: aenw commentedDoes this tutorial work in v. 7.x? Yup.
1. Very specifically: This tutorial *almost* works for me as written. I needed to change the XPath expression for the salary field a bit. The tutorial says to map the salary field to
salary/[@ccy="usd"]
but that throws an error for me. (Error: "There was an error with the XPath selector: Invalid expression") If I change it and take out the "/" so it is this:salary[@ccy="usd"]
then it works fine for me.Here's my configuration:- Drupal v. 7.7
- Feeds 7.x-2.0-alpha4
- Feeds XPath parser 7.x-1.0-beta2
2. Much more generally...
There have also been some comments on the tutorial page that show that others are having trouble being successful with this, too. That's a pretty good indicator that we need to add information/documentation so things are clarified. I'm willing to help out with this; I think this issue is a great place to start. Plus I'm just getting into all of this, so it's a great way for me to make sure I really understand Feeds. (That's also why this reply is so delayed.)
@F.G., here's the short answer to
You created a content type named "xml job feeds". You now need to create a node of one of those content types, either by going to
Create Content > xml job feeds
, or by going to the list of Feeds Importers, looking at the row for your ""Jobs XML Feeds" and clicking on "xml job feed" that's in the "Attached to:" column.When a "xml job feed" node is created manually (as opposed to being created automatically when a feed is scheduled by cron, etc), you can enter something like the date and time you're running this feed as the title. (You can ignore the body.) Scroll down and you'll see that Feeds has put in a fieldgroup. You'll see your Feed Fetcher (either a HTTP Fetcher or a File Uploader, depending on what you selected). Below that you should see a fieldgroup for XPath Parser Settings (the Parser you selected). When you expand that fieldgroup, you'll see fields for the context and each of the fields that you mapped as an XPath.
Enter the XPath expressions (you may need to make the change I noted above to salary). Check all of the debug boxes so you can see any messages generated. Save your changes.
Then run Import on your "xml job feed". If all is well, you will import the feed and create two nodes.
As for why you put the XPath expressions into a "xml job feed" node.... here's the much longer answer:
To review, here's an overview of the whole process:
A Feeds Importer is a factory: it takes in raw material (information from a feed) at one end, does three processing steps, and then spits out some shiny new nodes that are populated with the data from the feed at the other end.
(OK, sometimes it alters existing nodes. But not in this tutorial.)
Specifically, the three processing steps that a Feeds Importer does is:
So each time we read in a feed, we start with the raw feed input, have our Feed Importer factory run it through the three processing steps, and then produce (or alter) nodes.
We need a way to keep track of things when we run this process. We need to know exactly when the process was run (what day & time), and what the results were. And of course we need to keep track of the details: Exactly what was the data source we used when we ran this process? Did we have any special processing rules or information? What was the result? Were there any errors? Did we successfully create (or alter) nodes? (Imagine that your site is reading in a newsfeed every hour and generating dozens of nodes with news each time. Or that you've used feeds to import thousands of nodes from various data sources. Ya gotta keep track of all of that stuff.)
This is where the Feed Processor Node comes in to the picture. You need to create a content type so you can record the specific data source, any specific processing information, and results each time you process a feed. That is: each time you press the 'Import' button, and/or each time a job is scheduled to run to import a feed you have to keep track of what data you used, what you did, and what happened.
(I'm not yet clear on why you have to create a content type to do this, but that's how it is.)
In this tutorial, we create a content type called xml job feed -- and this is where you enter the XPath expressions
So finally, here's what we have for this tutorial:
(Note that when you see notation like "Fetcher > Change:" below, that's my shorthand for what you select on the user interface, e.g. for the Fetcher, click on Change.)
Fields to add to the job content type:
(You could also add a field for the 'publish date' but it's not covered in this tutorial.)
The specific settings and choices for our Jobs XML Feeds (a Feed Importer):
Whew.
Now we have the Feed Importer (Jobs XML Feeds) configured and set up and we have a content type created (xml job feed)so we can keep track of things each time we import data from our feed.
But now we're right at the crux of @F.G's question: in the Node Processor Mappings we said we would handle fields with XPath. Now we have to specify exactly what to do with those XPath fields.
We're going to create a new xml job feed node and give it information so that we can manually import this feed. Create the new node either by going to
Create Content > xml job feeds
, or by going to the list of Feeds Importers, looking at the row for your "Jobs XML Feeds" and clicking on "xml job feed" that's in the "Attached to:" column.When a "xml job feed" node is created manually (as opposed to being created automatically when a feed is scheduled by cron, etc), you can enter something like the date and time you're running this feed as the title. (You can ignore the body.) Scroll down and you'll see that Feeds has put in a fieldgroup. You'll see your Feed Fetcher (either a HTTP Fetcher or a File Uploader, depending on what you selected). Below that you should see a fieldgroup for XPath Parser Settings (the Parser you selected). When you expand that fieldgroup, you'll see fields for the context and each of the fields that you mapped as an XPath.
Here are the XPath expressions to enter and a note about what's going on with each:
<item>
element) for the XPath queries to follow<title></title>
tags in the feed to the field "title" in a job node<description></description>
tags in the feed to the field "body" in a job node<src>
tag, and map the value of the attribute "url" in the feed to the field "url" in a job node<salary>
tag, and if the value of the attribute "ccy" is equal to "usd" then map the value in that<salary></salary>
tag in the feed to the field "field_salary" in a job nodeCheck all of the debug boxes so you can see any messages generated. Save your changes.
Then run Import on your "xml job feed". If all is well, you will import the feed and create two nodes.
Yes, this did turn in to quite the document. But I hope it's helpful. Pipe up if you think we should polish this and add it to the documentation.
Anything not clear? Questions? Something not working?
- aenw
(now out of words for the day)
Comment #4
_petja CreditAttribution: _petja commentedI keep getting this error when importing:
An AJAX HTTP error occurred. HTTP Result Code: 500 Debugging information follows. Path: /batch?id=198&op=do StatusText: Internal Server Error ResponseText:
No matter what I try.
Any ideas?
Comment #5
dafreak CreditAttribution: dafreak commentedWhen I try to use XPath HTML Parser or XPath XML parser and I go to XPath parser settings, there are no settings options. Something is missing here.
dafreak
Comment #6
aenw CreditAttribution: aenw commented#4 @_petja: You should probably file a new issue. (And perhaps provide some specific information about your configuration: what version of java, what browser, etc.)
#5 @dafreak: This issue is really about the example tutorial. If something is broken with the project code, then you'll probably want to file a new issue. And then in your new issue you can set the component to 'Code' and the version to the specific version you have; this issue is about the documentation.
But first I'll try to help you figure out what's going on.
What are the versions you're running for: Drupal, Feeds, and Feeds XPath Parser?
And at what step in the tutorial do you run into a problem?
Comment #7
twistor CreditAttribution: twistor as a volunteer commentedClosing out old issues. If you're still having this problem, feel free to re-open it.