0

Possible Duplicate:
What is the fastest XML parser in PHP?

I still need to maintain the xml format, but I'm finding that my main bottleneck is the many calls I make to simplexml_load_file();

Community
  • 1
  • 1
Adola
  • 588
  • 7
  • 21
  • http://stackoverflow.com/questions/188414/best-xml-parser-for-php - Also check and evaluate/profile http://de2.php.net/manual/en/book.xml.php. – verisimilitude Jun 13 '12 at 05:13
  • I think Yankee has the right of it. I need to consider a way other than reading in .xml files, I think the actual reading from the harddrive is the big bottleneck here. – Adola Jun 13 '12 at 05:38
  • You must add more information to your question I'd say. The call is the bottleneck, fine, but is it the function or the file to be opened? Some more details and actually a code example would tell a thousand more words and would actually be helpful for others. – hakre Jun 13 '12 at 16:29

1 Answers1

0

simplexml_load_file itself is not that slow. The problem is the I/O that it causes, which will be expensive. Using a different method to parse your XML files won't make it much faster.

You can try to optimize your program to need to open the xml file less often or you could think about another way of saving your data, for example in a database to speed up the process.

hakre
  • 193,403
  • 52
  • 435
  • 836
yankee
  • 38,872
  • 15
  • 103
  • 162
  • You helped me in my other thread, hah. And if it is really an issue with I/O, then I think I'm sunk. I'm not sure how a database would fare. It's worth some form of consideration, but I have nearly no idea how to manipulate the XML data into a database. I have an XML file with 30k items, and each item has about 50 elements to it. Ugh.. – Adola Jun 13 '12 at 05:12
  • Mhh ok, that's in important info with the 30k... Maybe you can split into smaller files so that you don't need to parse the full file each time? Also: Consider a native XML Database such as eXist: http://exist-db.org. This way you don't need to remodel your xml file. – yankee Jun 13 '12 at 05:25
  • So it's not worth putting each element into a database? – Adola Jun 13 '12 at 05:28
  • Maybe. Its hard to tell without knowing exactly what kind of data your xml file contains and how your query it to say. There are flat XML files, there are native XML databases, there are relational databases, there are graph databases,... and they all have applications where they shine and some where they don't. If you have large amounts of data (as you do) and you need to query only excerpts, but those very often, then this calls for a database, but which kind of DB is another question. – yankee Jun 13 '12 at 05:38
  • Well, the server that's oh-so-graciously donating me space is running MySQL. I was thinking of trying to stick each element into the database, but I've no formal learning on how to even use a database properly. – Adola Jun 13 '12 at 05:41