0

I am receiving data from a third party company through XML. I want to add this to my website as drupal nodes, having some information like title, body, summary, image,...

I am able to make a cron job that reads all the data from the XML & write it to a database.

Now I was wondering:

  1. Can I write this to the database directly without creating any inconsistenties?

  2. What tables do I have to write this to? only the node table and the field_data tables? Or do I also have to add it to field_revision tables etc? Am I forgetting any others?

  3. Is there a module that's doing this? I tried the Feeds & the Migrate modules, but I can't seem to find anything to set up XML or SQL Data import on those. Either of the 2 is fine, whether it goes directly from the XML, or if I have to import it from SQL, cause then I can just add them to a temp table first.

Thank you very much

  • Please, be more concrete. For XML import via Feeds you can use Feeds extensible parsers What does "inconsistenties" mean? – ar7max Aug 30 '15 at 17:08
  • Well, I mean, if I would add new content to the database through a query, would drupal understand it? wouldn't there be other problems? like 2 nodes messing up eachother? For example, lets say I have a node 1000 in drupal, I make one through an SQL import, with id 1001, would drupal make the next as 1002, or would it use 1001 again (max(id)+1 or is there a table that keeps the highest number)? Or other possible problems like this – Digital Competitive Aug 30 '15 at 17:15
  • You can always look at drupal tables structure and see how it works. – ar7max Aug 30 '15 at 17:23
  • where do I see that? Or do you mean in the database? Cause that I checked, but that's my big question, if I forgot any. – Digital Competitive Aug 30 '15 at 17:46
1
  1. Can I write [the external data] to the database directly without creating any inconsistenties?

    • Hypothetically, yes. On a practical level, I'd avoid this approach like the plague. For example, in your next question, you ask…
  2. What tables do I have to write this to? only the node table and the field_data tables? Or do I also have to add it to field_revision tables etc? Am I forgetting any others?

    • Thanks for the segue. Why not use Drupal's Feeds module to consume your data and let Drupal and Feeds manage the consumption process? This will ensure all the data modeling, processing, security and coding best practices inherited by the larger community. Why would you bypass all the work that's gone into this development?
  3. Is there a module that's doing this? I tried the Feeds & the Migrate modules, but I can't seem to find anything to set up XML or SQL Data import on those. Either of the 2 is fine, whether it goes directly from the XML, or if I have to import it from SQL, cause then I can just add them to a temp table first.

    • As ar7Max indicates, you can use the Feeds and Feeds XPath Parser. It's stable, mature and has a large user base. We rely on this combination heavily (50+ sites, 100's of specific feeds imports) mostly without a hitch. The hitch tends to be poorly formed XML output which can break an import — again, this is rare and addressable at the source OR using Feeds Tamper. where you can rewrite the XML data as needed. If you wish, ask your XPath Parser specific questions here — once you understand it, it's trivial to manage.
  • Thank you very much. however, I don't seem to understand the Feeds Module, I followed a tutorial to use this, and all I received were errors. – Digital Competitive Aug 30 '15 at 18:03
  • We can start a stackexchange chat and I'd be happy to troubleshoot this with you — if you'd like. – Screenack Aug 30 '15 at 18:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.