1

I am working on a small app that utilizes a game API, unfortunately the API is not the fastest in the universe. It also only outputs large XML files.

I want to grab one of these files and place it directly into a database, this way it is not being queried from their servers each time a user needs to update something. Instead its querying my local database. I would grab it via a cron job every few hours, thus it shouldn't affect performance.

My question is: What is the most efficient way for me to grab the XML file from their server and update my database with their updated version? [As a note, I am using only PHP for this and want to keep it that way.

Thank you for your assistance!

1 Answer 1

1

I would parse the XML-file from their server using something like simpleXML.

I guess the XML-files have elements which are basically the same with other values? In this case, you'll want to create a PreparedStatement and bind new parameters for every entry. This is the most performant way to do this.

But if you care mostly about performance, PHP isn't the way to go. You could use Java (for example) to parse the XML-File and write the entry's in your Database. With which language you access the filled database is of no concern.

Sign up to request clarification or add additional context in comments.

5 Comments

Creating a java program to periodically parse the xml will not be much faster than just using php... Esp when he'd probably have to learn java... Not worth the trouble...
If he needs to learn another language it's really not worth the trouble. Assuming that he's already familiar with Java/C, it think parsing the XML file with those is a bit faster.
Thank you for your answer, I am using simple xml now but thought that there is a better way of handling this. It can be a little on the slow side. I will leave this question open for a while longer and see if another answer pops up.
No, simpleXML isn't the fastest (but surly the easiest). I found thath interesting article which covers this as well.
Ah thank you for that link, I will take a look at learning more about XMLReader.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.