|
|
Subject:
Parsing a mySQL database
Category: Computers > Programming Asked by: jmo88-ga List Price: $5.00 |
Posted:
28 Jul 2004 16:17 PDT
Expires: 27 Aug 2004 16:17 PDT Question ID: 380500 |
I have a mySQL database that I want to extract information from and port it to a particular software. For that end software, I have an XML DTD, that defines how data should be formatted in order to import it. My question is, what is the best programming language (which would you recommend) to parse a MySQL DB, and convert the information to an XML format as defined by the DTD? OR, can I just use MySQL to output information from a DB to a format that I've defined??? ****************Here's more details******************* Here's an example of a portion of what I want to do: the database has a table called 'router.' Each router in the table will be identified by its 'name.' For the software I'm using, I need an XML (text) file that has a line for each router that looks like this: <node name="router1" type="router"> <other info...> </node> <node name="router2" type="router"> <other info...> </node> | |
|
|
There is no answer at this time. |
|
Subject:
Re: Parsing a mySQL database
From: crythias-ga on 28 Jul 2004 18:23 PDT |
I'd say PHP :) It's built very well to handle things like this. The steps are essentially open the database, query the table, output the information. <? php $host="localhost"; $user="username"; $password="sekrit"; $db="routerdb"; $link = mysql_connect($host,$user,$pwd) or die("Could not connect to Host."); mysql_select_db($db) or die("Could not select database."); $query="SELECT name, info, otherfield FROM table"; $result = mysql_query($query) or die("Could not run query." . mysql_error()); while ($answer = mysql_fetch_object($result)) { echo "<node name=\"" . $answer->name . "\" type=\"router\"><" . $answer->info . "> </node>\n"; } ?> Redirect ourput to your file. |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
Search Google Answers for |
Google Home - Answers FAQ - Terms of Service - Privacy Policy |