I need to create a custom XML-feed. Is this possible with feeds?
If so, how to and... Where can i set the 'root node' of the XML?
Also, I'm adding fields to this XML but these fields need to be wrapped within other elements, how can i accomplish this?
e.g.
<?xml version="1.0" encoding="UTF-8"?>
THIS IS THE 'ROOT NODE' i need to add.
CAN I CHANGE NODE TO ANOTHER TERM LIKE e.g. ?
THESE ARE ELEMENTS TO ADD AROUND THE FIELD
THIS IS THE DATE_FIELD
So to resume: i only have the field 'date' and everything around (calendar, timestamps, timestamp) i need to add. This needs to be done for almost all fields needed.
The meaning of this all is to export XML customised according to a custom xml-standard. I haven't found a module capable to do this yet, so please advise.
Please advise.
Comments
Comment #1
WilliamV commented--- CORRECTION ---
I need to create a custom XML-feed. Is this possible with feeds?
If so, how to and... Where can i set the 'root node' of the XML?
Also, I'm adding fields to this XML but these fields need to be wrapped within other elements, how can i accomplish this?
e.g.
So to resume: i only have the field 'date' and everything around (calendar, timestamps, timestamp) i need to add. This needs to be done for almost all fields needed.
The meaning of this all is to export XML customised according to a custom xml-standard. I haven't found a module capable to do this yet, so please advise.
Please advise
Comment #2
ChaosD commentedViews bonus export can do this in d6... not sure for d7, sorry :(
Comment #3
WilliamV commentedOk, how was this done with D6?
Thx!
Comment #4
ChaosD commentedyou create a view with fields containing the stuff you want and on the left site where you can add a page or a block view there should be XML, too if you installed the views bonus pack.
Comment #5
WilliamV commentedYes but: can i alter the exported xml within this view to add/change elements?
Thank you.
Comment #6
ChaosD commentedyou could try arranging the fields that they are displayed like this... never tried it that way, sorry
Comment #7
thedavidmeister commentedno. feeds does not do this.
feeds is for *importing* data from other formats only, so this isn't really relevant to this issue queue.
you may try looking into the services module, it allows you to expose your Drupal data to the outside world in various ways, i assume that an XML feed would be one of them http://drupal.org/project/services
Comment #8
shura80 commentedOnce you have created a simple module to generate your xml structure (you just have to print the xml open tags and fill the xml with data taken from your fields), you could use one of the Feeds plugin modules to import XML sources into Drupal nodes
One of the most useful is feeds_xpathparser.
At the beginning, something like:
Then, for example, use a custom object ($data) to store all your needed fields extracted with a query and print them with something like:
You should now have for example a menu link in your module to call the path where this XML will be created and you could use the same link to tell Feeds where is the xml source to load, using the feeds_xpathparser to map xml tags into drupal node fields
Hope this will be helpful :)
Comment #9
WilliamV commentedIll have a look into this and will keep you informed. Thank you for the response.
Comment #10
thedavidmeister commentedyou can create a "Feed" using Views and then create a tpl.php file to customize the output relatively easily. Templates to work from can be found in View's module directory.
it is one of those things that sounds scary, but if you work through it step by step, you'll be all done in a few hours without too much WTF along the way :)
Comment #11
dakke commentedCould you elaborate a bit?
I manage creating the tpl.php file, and get the field variables using
<pre><?php print_r ($view); ?></pre>.From there I'm stuck. Using views 2, I'm told that given there is a field variable called node_title, the following ought to work:
<?php print $fields['node_title']->content; ?>Yet it does not. Nothing is printed, so bit stuck here. Any suggestions or tutorials out there...?
Comment #12
thedavidmeister commentedwhy not dpm() the $fields variable?
Comment #13
dakke commentedCould you elaborate/explain a bit?
For using
dpm($view);I get the fields, yet printing out these fields does not seem to do much.I tried the
print $fields['title']->content;, but no result. Yet, the field is called title...Comment #14
thedavidmeister commentedOk, well could you elaborate/explain your reasoning a bit first?
If you dpm() a variable called $view, that has nothing to do with the output produced by printing part of a variable called $fields. So why would you expect
print $fields['xxx']->yyy;to do anything at all based on the reasoning that you inspected $view?If you believe that what you're after is in a variable called $fields you should dpm $fields and step through the object/array to find what you're looking for.
The exact structure of variables in a tpl.php file rely on the arguments sent through the theme function and what happens in the pre-processor, so you're pretty much guaranteed to need to use some kind of development tool to probe the data you're working with if you want to eliminate guesswork.
The problem is either the variable is there, in the tpl.php file and you can't figure out how to reference it, or it isn't there at all and you'll have to investigate further with your site's setup to get the right data into your template.
If the problem is the former, you'll know instantly if you put this in your tpl.php file:
That will show you all the variables you have available in the current scope. If what you're after isn't in that list, you can't use it yet.
Comment #15
dakke commentedThanks for the reply.
This is probably over my head at this point. I 'simply' tried the docs of views 2, explaining how to print the fields and get the fields variables.
I followed this doc and thought that it would do what was mentioned there. However, step 4: identifying your template variables, and more specifically identifying field variables did not do anything. It said that
dsm(array_keys($fields));would print out the fields and that with<?php print $fields['foo']->content; ?>I would be able to print them out.But
dsm(array_keys($fields));doesn't print anything, nothing there.I assume that this therefore means that the variables are not there as I would expect them to. Suggestions surely welcome, but I don't get it.
Comment #16
thedavidmeister commentedWell when I did it, because I had set up my view and override slightly differently to the way they did in that tutorial I had to use the $themed_rows and $rows variables instead of the $fields variable. Because of the way the Drupal theme system works it really isn't that unlikely that a variable called $fields doesn't exist but something analogous does in the specific template file you're trying to override.
Basically, the data available in any tpl.php file has been generated and may have been "pre-processed" a few times already in "deeper" layers of the code by other modules so the tutorial you're referencing may be too "vanilla" for the site you're working on. Or maybe not, who knows? That's up to you to figure out; learning how to extract a printout of data like this from the system when you need it without resorting to google is a valuable skill.
Try what I suggested, not what is in that tutorial, and put
In your tpl.php file. If you get a nice printout of all your variables, that's great, use that to find the one that contains the data you're looking for.
If you get absolutely nothing, you've either got devel disabled, you don't have permission to see devel printouts, devel isn't installed correctly (make sure you can get krumo displaying in other places correctly), you haven't named your tpl.php file correctly or you haven't cleared your cache since creating the tpl.php file in your enabled theme.
If you're absolutely certain your tpl.php file is correctly named (because you checked the theme information in the views UI) and suspect that devel is playing up then do this instead:
It will give you the same info but won't look as nice and won't always be displayed in the same part of the page as it will be inline with other rendered html, so you might have to go fishing through the source to find it.
This thread is closed btw. The OP's question was answered in #7 - You can't use the Feeds module to create an XML Feed, the Feeds module is only useful for importing external feed items into Drupal.
If you need further advice, please open a support issue in the Views module's issue queue and leave a link here for others to follow.