June 29, 200917 yr I've got multiple XML files that I need to be able to search, display and filter as if just one file. Is this possible? Would the XML's need merging first? or would it be easier to merge all the XML data in to a MySQL DB? (and is that possible?). It probably has a simple answer but my learning curve has been a little steep of late and I'm getting a little unstuck in places. Any help would be appreciated.
June 29, 200917 yr I guess it depends on exactly how you're doing the searching/filtering and whether, for example, order matters. It's always possible to examine each file in turn, pick the relevant records, store them in memory and then do ordering afterwards. But that may involve considerable caching (memory usage) and decent search algorithms. You really won't gain anything from dumping the XML into a database unless you want to access that data frequently. If it's just a one-off processing job, you might as well do a parse from the XML, manipulate the data and produce the output (which you can then cache in HTML format to improve performance if it doesn't change often). There are a lot of considerations, caveats and possibilities and you'll need to be more specific to get decent help.
June 29, 200917 yr Author I would give you exact details but there's still some fleshing out to do so the best I can give is an example. Say for instance I had multiple XML files, each file containing details related to a single manufacturers power/hand tools. eg, bosch, dewalt, hilti, etc and within each file were sub-categories and relevant product details (type, size, weight, voltage, use, attachment compatibility, safety sheet, log number). What I need to be able to do is either search by a specific product name or filter all products spread accross multiple pages by clicking on various presets. Clicking on a 110V button would only show tools that use 110V etc And as an advanced search I would like to have a wizard type search. You would select multiple options then click search and the relevant results would be displayed. The XML data would be updated bi-weekly or monthly depending on manufacturer.
June 30, 200917 yr Since your files are updating quite infrequently and you want the possibility for all kinds of searches, personally I'd write a script to dump the XML files into a database, then use the database's querying to search. The way databases can optimise their storage and querying via indices and caching will hugely improve performance and be the most flexible option in the long run. It'll also make your life considerably easier - always a "good thing"!
July 1, 200917 yr Author Since your files are updating quite infrequently and you want the possibility for all kinds of searches, personally I'd write a script to dump the XML files into a database, then use the database's querying to search. The way databases can optimise their storage and querying via indices and caching will hugely improve performance and be the most flexible option in the long run. It'll also make your life considerably easier - always a "good thing"! Is there a way of importing an xml to MySQL via cpanel/phpmyadmin. There's an import option but it doesn't specify xml and I'm not too familiar with MySQL. How are MySQL PHP queries displayed within a html document?
July 1, 200917 yr Is there a way of importing an xml to MySQL via cpanel/phpmyadmin. There's an import option but it doesn't specify xml and I'm not too familiar with MySQL. As far as I'm aware, there is no way to generically convert XML into SQL - every document is different and every database is different, so how could a program (or Web script) know how to convert the data in XML to database tables and fields? There are just too many possibilities to make it work without your own code. So you'd need to code this yourself, parsing the XML document (using something like PHP's XML Parser library) and inserting that data into your database in whatever format you require. Naturally you could do this as a desktop program or server-side executable as an alternative to a webpage, if you know how and would find that more useful. An example would be running a server-side executable via cron every day to ensure the latest XML files are merged into the database automatically each night. How are MySQL PHP queries displayed within a html document? I'm not quite sure what you mean: a MySQL query (which has nothing to do with PHP) will merely return a set of results (e.g. a subset of rows in a particular table). To input a query via your website, you need to design an HTML form which contains all the options you need for searching, then write a PHP script to process the POST-back of that form. This script will construct and execute the database query. It is then up to you to program a second set of PHP code to display the results from the query in a way that is clear and useful to your users. This isn't easy, but it is doable. I'd suggest starting as simple as you can and then adding more search options in one-by-one later. (Note I assumed you're dealing with PHP since you mention it; obviously any other server-side scripting language would do the job too, but none are as commonly used as PHP)
July 1, 200917 yr Author I'm not quite sure what you mean: a MySQL query (which has nothing to do with PHP) will merely return a set of results (e.g. a subset of rows in a particular table). sorry, what I meant was the code generated in cpanel eg $sql = 'SELECT * FROM `test` ORDER BY `product` ASC LIMIT 0, 30 ';
July 1, 200917 yr sorry, what I meant was the code generated in cpanel eg $sql = 'SELECT * FROM `test` ORDER BY `product` ASC LIMIT 0, 30 '; If you're asking how to execute that query in a PHP page and get a result set back, you should probably read a tutorial like this one: MySQL Tutorial. It'll walk you through the steps, the major ones being creating a connection, executing a query, and obtaining the results.
July 2, 200917 yr Author thanks. I quite like the way dabs.com filters products; for instance - dabs.com. Do you know how it has been done? Is it javascript? And would it be possible to replicate with a database?
Create an account or sign in to comment