Answer the question
In order to leave comments, you need to log in
Parsing .xml file into mysql database?
Good afternoon, I ask for advice in solving the issue of parsing data into the mysql database. A file like this:
<response>
<systime0>2324</systime0>
<iovalue0>1000000000000000000001</iovalue0>
<pwm0>0</pwm0>
<adc0>635</adc0>
<adc1>561</adc1>
<adc2>527</adc2>
<adc3>652</adc3>
<count0>0</count0>
<count1>0</count1>
<count2>0</count2>
<count3>0</count3>
<slow_info0/>
<cat_inf0/>
<cat_cnt0/>
</response>
Answer the question
In order to leave comments, you need to log in
Do you need it?
$xml = '<response>
<systime0>2324</systime0>
<iovalue0>1000000000000000000001</iovalue0>
<pwm0>0</pwm0>
<adc0>635</adc0>
<adc1>561</adc1>
<adc2>527</adc2>
<adc3>652</adc3>
<count0>0</count0>
<count1>0</count1>
<count2>0</count2>
<count3>0</count3>
<slow_info0/>
<cat_inf0/>
<cat_cnt0/>
</response>';
$data = new SimpleXMLElement($xml);
$data = str_split($data->iovalue0);
$data = implode('|', $data);
var_dump($data);
// Результат
string '1|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|1' (length=43)
It is necessary from 1000000000000000000001 to
get the table |1|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|1 |
Something like this.
Bears, your answer is very similar to the "str_split" solution, but you can suggest how to use it. Sorry, I'm a layman in this matter.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question