php - how insert data from xml to mysql with loops -


enter code here`hi how can me ? have problem in script

i want save xml file in 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 </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 7 templates want save settings tags in style information table 1 time table style_name varchar(255) version varchar(255)

and want save 7 template in mysql table

table map

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

please me

you use simplexml-class parse xml file , use mysqli-class write values in database.

examples , tutorials on both things can found in php-manual, comments in php-manual , on google.

step step:

  1. parse xml-file , values (save them in array)
  2. connect mysql database
  3. create preparedstatement insert
  4. loop on array , insert values in database
  5. close database connection

Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -