0

I load more than 50 XML files on my homepage. An example structure you can see here:

http://api.eve-central.com/api/marketstat?usesystem=30000142&hours=24&typeid=3683&minQ=10000

I need the price "sell" -> "min". So currently I run foreach() loops and stop when got it. But my page needs more than 30 seconds to handle this, I think I need a direct entry to the data like:

$min = $xml -> children() -> children() -> sell -> min;

Can anybody give me the right arithmetik?

Thx step

2
  • Is there any indication as to how often those figures are updated? If every minute then consider caching the finished page every minute and serving that up. Commented Aug 26, 2013 at 12:57
  • Those “files” are actually not files, but HTTP resources – and downloading 50 of them just takes a certain amount of time. As @Cups already said, see if you can cache those instead of reading them again every time. Commented Aug 26, 2013 at 13:39

2 Answers 2

1

Use simplexml_load_file function. Its so simply and quick!

$xml = simplexml_load_file('http://api.eve-central.com/api/marketstat?usesystem=30000142&hours=24&typeid=3683&minQ=10000');

echo $xml->marketstat->type->sell->min; // 257.99

And SimpleXMLElement and file_get_contents

$xml_str = file_get_contents('http://api.eve-central.com/api/marketstat?usesystem=30000142&hours=24&typeid=3683&minQ=10000');
$xml = new SimpleXMLElement($xml_str);

echo $xml->marketstat->type->sell->min;  // 257.99
Sign up to request clarification or add additional context in comments.

3 Comments

+1 Thx thats what i search, but it doesnt make my code faster :(. It also takes 30seconds to load 57 of this files, is it normal??? The 57 data i load the same way like u show, i think its the fastest way or?
simplexml is best one of xml parsers that I know.
ok thx a lot!!! i save data in sql and update it via cronjobs, so my problem is solved !!
0

Interestingly enough, i am also working with the eve-central api at the moment. I have to give you a great tip though, eve-central allows you to pass requests for more than one item.

http://api.eve-central.com/api/marketstat?typeid=3683&typeid=3684&typeid=3685&typeid=3686&typeid=3687&typeid=3688&typeid=3689&usesystem=30000142&hours=24&minQ=10000

Like that.

Build a nice for loop that gets all the id's you want and let that construct an url like that. Once done adding all the &typeid=, add &usesystem=30000142&hours=24&minQ=10000 to it and do the simplexml_load_file(the name of your url here);

Now you can do a foreach on the xml output you get for all the items you wanted all at once.

Comments

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.