0

enter code here`hi how can help me ? i have Problem in my script

i want save this xml file in the mysql db

the xml file

   <?xml version="1.0" encoding="utf-8"?>


<STYLE>




<settings><style_name>default</style_name>
<style_version>1.0</style_version>
</settings>



<tpl>

<tpl_name>body</tpl_name>
<tpl_display_area>body</tpl_display_area>
<tpl_des>body</tpl_des>
<tpl_source><![CDATA[<
Body src
]]></tpl_source>



<tpl_name>footer</tpl_name><tpl_display_area>footer</tpl_display_area><tpl_des>footer</tpl_des>
<tpl_source>
<![CDATA[>

source Footer
]]>
</tpl_source>
<tpl_name>closing</tpl_name><tpl_display_area>close</tpl_display_area><tpl_des>closing</tpl_des><tpl_source><![CDATA[<center><h3>Our website close right now </h3></center>]]></tpl_source>




<tpl_name>display</tpl_name>
<tpl_display_area>display</tpl_display_area>
<tpl_des>display</tpl_des>
<tpl_source>
<![CDATA[{include file='db:header'}
{include file='db:body'}
{include file='db:footer'}]]>
</tpl_source>





<tpl_name>right block</tpl_name>
<tpl_display_area>right_block</tpl_display_area>
<tpl_des>right block</tpl_des>
<tpl_source><![CDATA[ right src ]]></tpl_source>
<tpl_name>left block</tpl_name>
<tpl_display_area>left_block</tpl_display_area>
<tpl_des>left block</tpl_des>
<tpl_source>
<![CDATA[<div class="left">
</div>]]>
</tpl_source>


<tpl_name>header</tpl_name>
<tpl_display_area>header</tpl_display_area>
<tpl_des>header</tpl_des><tpl_source><![CDATA[<head></head>]]></tpl_source>
</tpl>
</STYLE>

There was 7 templates i want to save settings tags in the style information table one time only the table style_name varchar(255) version varchar(255)

and want save all 7 template in mysql table

table Map

tpl_name varchar(255) tpl_display_area varchar(255) tpl_des varchar(255) tpl_source text

please help me

1
  • What exactly is your question, what part of the process are you stuck with? Commented May 11, 2011 at 7:36

1 Answer 1

1

You could use the SimpleXML-class to parse the XML file and then use the MySQLi-class to write the values in the Database.

Examples and Tutorials on both this things can be found in the PHP-Manual, the Comments in the PHP-Manual and on Google.

Step by Step:

  1. Parse your XML-File and get the Values from it (save them in an Array)
  2. Connect to your MySQL Database
  3. Create a PreparedStatement for the Insert
  4. Loop over your Array and Insert the Values in the Database
  5. Close the Database connection
Sign up to request clarification or add additional context in comments.

4 Comments

thanks for answerd my question but im trying all that i did not understand any thing if you can apply all that on my file and i will see it
We are not going to do your work. Read the Tutorials, check the Documentation and see if you can do it yourself. If you come up with any errors, feel free to ask here.
i dont want you to do my work only i want you to explain me how i can do this operation
Edited my post. This should give a basic idea of the workflow. Try to implement it and ask here, if you come up with any errors.

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.