- Joined
- Feb 8, 2009
- Messages
- 112
- Reaction score
- 0
Hello everyone. I need help with php scripting. Here is thing.
I have file:
And i need to make a php script which will open that file and divide it in separate files. But i need to divide it specifically. It should start reading file and look for <items> and copy from beginning of <items> through end of </items>. And then save it to new file with its id.
Here is example
it will copy this:
and then look for id after type="int"> until </variable> in this case it would be 9580.
i need this script because a got like 200files and 30 XML codes in each files, and i need add each XML code into mysql database. it would be cool if anyone could help me with this. i know how to open file and write it to mysql but i dono how to make it copy specific partion of it and save it to a file with its id or do something else with it.
p.s. sorry if it doesnt make seance. ask questions and i will answer if something isnt clear
======== Added +++
after some research i found this http://us.php.net/manual/en/function.file.php
and also figured out that using C++ or other programming language will be easier.
I have file:
Code:
<items><variable name="id" type="int">9564</variable>
<variable name="pos" type="int">1</variable>
<variable name="count" type="int">1</variable>
<variable name="max_count" type="int">1</variable>
<variable name="data" type="Octets"></variable>
<variable name="proctype" type="int">0</variable>
<variable name="expire_date" type="int">0</variable>
<variable name="guid1" type="int">1202570355</variable>
<variable name="guid2" type="int">1244</variable>
<variable name="mask" type="int">0</variable>
</items>
<items><variable name="id" type="int">9566</variable>
<variable name="pos" type="int">2</variable>
<variable name="count" type="int">1</variable>
<variable name="max_count" type="int">1</variable>
<variable name="data" type="Octets"></variable>
<variable name="proctype" type="int">0</variable>
<variable name="expire_date" type="int">0</variable>
<variable name="guid1" type="int">1202570355</variable>
<variable name="guid2" type="int">1244</variable>
<variable name="mask" type="int">0</variable>
</items>
<items><variable name="id" type="int">9568</variable>
<variable name="pos" type="int">3</variable>
<variable name="count" type="int">1</variable>
<variable name="max_count" type="int">1</variable>
<variable name="data" type="Octets"></variable>
<variable name="proctype" type="int">0</variable>
<variable name="expire_date" type="int">0</variable>
<variable name="guid1" type="int">1202570355</variable>
<variable name="guid2" type="int">1244</variable>
<variable name="mask" type="int">0</variable>
</items>
<items><variable name="id" type="int">9570</variable>
<variable name="pos" type="int">4</variable>
<variable name="count" type="int">1</variable>
<variable name="max_count" type="int">1</variable>
<variable name="data" type="Octets"></variable>
<variable name="proctype" type="int">0</variable>
<variable name="expire_date" type="int">0</variable>
<variable name="guid1" type="int">1202570355</variable>
<variable name="guid2" type="int">1244</variable>
<variable name="mask" type="int">0</variable>
</items>
<items><variable name="id" type="int">9572</variable>
<variable name="pos" type="int">5</variable>
<variable name="count" type="int">1</variable>
<variable name="max_count" type="int">1</variable>
<variable name="data" type="Octets"></variable>
<variable name="proctype" type="int">0</variable>
<variable name="expire_date" type="int">0</variable>
<variable name="guid1" type="int">1202570355</variable>
<variable name="guid2" type="int">1244</variable>
<variable name="mask" type="int">0</variable>
</items>
<items><variable name="id" type="int">9582</variable>
<variable name="pos" type="int">6</variable>
<variable name="count" type="int">1</variable>
<variable name="max_count" type="int">1</variable>
<variable name="data" type="Octets"></variable>
<variable name="proctype" type="int">0</variable>
<variable name="expire_date" type="int">0</variable>
<variable name="guid1" type="int">1202570355</variable>
<variable name="guid2" type="int">1244</variable>
<variable name="mask" type="int">0</variable>
</items>
<items><variable name="id" type="int">9584</variable>
<variable name="pos" type="int">7</variable>
<variable name="count" type="int">1</variable>
<variable name="max_count" type="int">1</variable>
<variable name="data" type="Octets"></variable>
<variable name="proctype" type="int">0</variable>
<variable name="expire_date" type="int">0</variable>
<variable name="guid1" type="int">1202570355</variable>
<variable name="guid2" type="int">1244</variable>
<variable name="mask" type="int">0</variable>
</items>
<items><variable name="id" type="int">9590</variable>
<variable name="pos" type="int">8</variable>
<variable name="count" type="int">1</variable>
<variable name="max_count" type="int">1</variable>
<variable name="data" type="Octets"></variable>
<variable name="proctype" type="int">0</variable>
<variable name="expire_date" type="int">0</variable>
<variable name="guid1" type="int">1202570355</variable>
<variable name="guid2" type="int">1244</variable>
<variable name="mask" type="int">0</variable>
</items>
<items><variable name="id" type="int">9592</variable>
<variable name="pos" type="int">9</variable>
<variable name="count" type="int">1</variable>
<variable name="max_count" type="int">1</variable>
<variable name="data" type="Octets"></variable>
<variable name="proctype" type="int">0</variable>
<variable name="expire_date" type="int">0</variable>
<variable name="guid1" type="int">1202570355</variable>
<variable name="guid2" type="int">1244</variable>
<variable name="mask" type="int">0</variable>
</items>
<items><variable name="id" type="int">9594</variable>
<variable name="pos" type="int">10</variable>
<variable name="count" type="int">1</variable>
<variable name="max_count" type="int">1</variable>
<variable name="data" type="Octets"></variable>
<variable name="proctype" type="int">0</variable>
<variable name="expire_date" type="int">0</variable>
<variable name="guid1" type="int">1202570355</variable>
<variable name="guid2" type="int">1244</variable>
<variable name="mask" type="int">0</variable>
</items>
<items><variable name="id" type="int">9602</variable>
<variable name="pos" type="int">11</variable>
<variable name="count" type="int">1</variable>
<variable name="max_count" type="int">1</variable>
<variable name="data" type="Octets"></variable>
<variable name="proctype" type="int">0</variable>
<variable name="expire_date" type="int">0</variable>
<variable name="guid1" type="int">1202570355</variable>
<variable name="guid2" type="int">1244</variable>
<variable name="mask" type="int">0</variable>
</items>
<items><variable name="id" type="int">9574</variable>
<variable name="pos" type="int">12</variable>
<variable name="count" type="int">1</variable>
<variable name="max_count" type="int">1</variable>
<variable name="data" type="Octets"></variable>
<variable name="proctype" type="int">0</variable>
<variable name="expire_date" type="int">0</variable>
<variable name="guid1" type="int">1202570355</variable>
<variable name="guid2" type="int">1244</variable>
<variable name="mask" type="int">0</variable>
</items>
<items><variable name="id" type="int">9576</variable>
<variable name="pos" type="int">13</variable>
<variable name="count" type="int">1</variable>
<variable name="max_count" type="int">1</variable>
<variable name="data" type="Octets"></variable>
<variable name="proctype" type="int">0</variable>
<variable name="expire_date" type="int">0</variable>
<variable name="guid1" type="int">1202570355</variable>
<variable name="guid2" type="int">1244</variable>
<variable name="mask" type="int">0</variable>
</items>
<items><variable name="id" type="int">9578</variable>
<variable name="pos" type="int">14</variable>
<variable name="count" type="int">1</variable>
<variable name="max_count" type="int">1</variable>
<variable name="data" type="Octets"></variable>
<variable name="proctype" type="int">0</variable>
<variable name="expire_date" type="int">0</variable>
<variable name="guid1" type="int">1202570355</variable>
<variable name="guid2" type="int">1244</variable>
<variable name="mask" type="int">0</variable>
</items>
<items><variable name="id" type="int">9586</variable>
<variable name="pos" type="int">15</variable>
<variable name="count" type="int">1</variable>
<variable name="max_count" type="int">1</variable>
<variable name="data" type="Octets"></variable>
<variable name="proctype" type="int">0</variable>
<variable name="expire_date" type="int">0</variable>
<variable name="guid1" type="int">1202570355</variable>
<variable name="guid2" type="int">1244</variable>
<variable name="mask" type="int">0</variable>
</items>
<items><variable name="id" type="int">9588</variable>
<variable name="pos" type="int">16</variable>
<variable name="count" type="int">1</variable>
<variable name="max_count" type="int">1</variable>
<variable name="data" type="Octets"></variable>
<variable name="proctype" type="int">0</variable>
<variable name="expire_date" type="int">0</variable>
<variable name="guid1" type="int">1202570355</variable>
<variable name="guid2" type="int">1244</variable>
<variable name="mask" type="int">0</variable>
</items>
<items><variable name="id" type="int">9596</variable>
<variable name="pos" type="int">17</variable>
<variable name="count" type="int">1</variable>
<variable name="max_count" type="int">1</variable>
<variable name="data" type="Octets"></variable>
<variable name="proctype" type="int">0</variable>
<variable name="expire_date" type="int">0</variable>
<variable name="guid1" type="int">1202570355</variable>
<variable name="guid2" type="int">1244</variable>
<variable name="mask" type="int">0</variable>
</items>
<items><variable name="id" type="int">9598</variable>
<variable name="pos" type="int">18</variable>
<variable name="count" type="int">1</variable>
<variable name="max_count" type="int">1</variable>
<variable name="data" type="Octets"></variable>
<variable name="proctype" type="int">0</variable>
<variable name="expire_date" type="int">0</variable>
<variable name="guid1" type="int">1202570355</variable>
<variable name="guid2" type="int">1244</variable>
<variable name="mask" type="int">0</variable>
</items>
<items><variable name="id" type="int">9604</variable>
<variable name="pos" type="int">19</variable>
<variable name="count" type="int">1</variable>
<variable name="max_count" type="int">1</variable>
<variable name="data" type="Octets"></variable>
<variable name="proctype" type="int">0</variable>
<variable name="expire_date" type="int">0</variable>
<variable name="guid1" type="int">1202570355</variable>
<variable name="guid2" type="int">1244</variable>
<variable name="mask" type="int">0</variable>
</items>
<items><variable name="id" type="int">9606</variable>
<variable name="pos" type="int">20</variable>
<variable name="count" type="int">1</variable>
<variable name="max_count" type="int">1</variable>
<variable name="data" type="Octets"></variable>
<variable name="proctype" type="int">0</variable>
<variable name="expire_date" type="int">0</variable>
<variable name="guid1" type="int">1202570355</variable>
<variable name="guid2" type="int">1244</variable>
<variable name="mask" type="int">0</variable>
</items>
<items><variable name="id" type="int">9608</variable>
<variable name="pos" type="int">21</variable>
<variable name="count" type="int">1</variable>
<variable name="max_count" type="int">1</variable>
<variable name="data" type="Octets"></variable>
<variable name="proctype" type="int">0</variable>
<variable name="expire_date" type="int">0</variable>
<variable name="guid1" type="int">1202570355</variable>
<variable name="guid2" type="int">1244</variable>
<variable name="mask" type="int">0</variable>
</items>
<items><variable name="id" type="int">9610</variable>
<variable name="pos" type="int">22</variable>
<variable name="count" type="int">1</variable>
<variable name="max_count" type="int">1</variable>
<variable name="data" type="Octets"></variable>
<variable name="proctype" type="int">0</variable>
<variable name="expire_date" type="int">0</variable>
<variable name="guid1" type="int">1202570355</variable>
<variable name="guid2" type="int">1244</variable>
<variable name="mask" type="int">0</variable>
</items>
<items><variable name="id" type="int">10060</variable>
<variable name="pos" type="int">23</variable>
<variable name="count" type="int">1</variable>
<variable name="max_count" type="int">1</variable>
<variable name="data" type="Octets"></variable>
<variable name="proctype" type="int">0</variable>
<variable name="expire_date" type="int">0</variable>
<variable name="guid1" type="int">1202570355</variable>
<variable name="guid2" type="int">1244</variable>
<variable name="mask" type="int">0</variable>
</items>
<items><variable name="id" type="int">9600</variable>
<variable name="pos" type="int">24</variable>
<variable name="count" type="int">1</variable>
<variable name="max_count" type="int">1</variable>
<variable name="data" type="Octets"></variable>
<variable name="proctype" type="int">0</variable>
<variable name="expire_date" type="int">0</variable>
<variable name="guid1" type="int">1202570355</variable>
<variable name="guid2" type="int">1244</variable>
<variable name="mask" type="int">0</variable>
</items>
<items><variable name="id" type="int">9580</variable>
<variable name="pos" type="int">25</variable>
<variable name="count" type="int">1</variable>
<variable name="max_count" type="int">1</variable>
<variable name="data" type="Octets"></variable>
<variable name="proctype" type="int">0</variable>
<variable name="expire_date" type="int">0</variable>
<variable name="guid1" type="int">1202570355</variable>
<variable name="guid2" type="int">1244</variable>
<variable name="mask" type="int">0</variable>
</items>
And i need to make a php script which will open that file and divide it in separate files. But i need to divide it specifically. It should start reading file and look for <items> and copy from beginning of <items> through end of </items>. And then save it to new file with its id.
Here is example
it will copy this:
Code:
<items><variable name="id" type="int">9580</variable>
<variable name="pos" type="int">25</variable>
<variable name="count" type="int">1</variable>
<variable name="max_count" type="int">1</variable>
<variable name="data" type="Octets"></variable>
<variable name="proctype" type="int">0</variable>
<variable name="expire_date" type="int">0</variable>
<variable name="guid1" type="int">1202570355</variable>
<variable name="guid2" type="int">1244</variable>
<variable name="mask" type="int">0</variable>
</items>
i need this script because a got like 200files and 30 XML codes in each files, and i need add each XML code into mysql database. it would be cool if anyone could help me with this. i know how to open file and write it to mysql but i dono how to make it copy specific partion of it and save it to a file with its id or do something else with it.
p.s. sorry if it doesnt make seance. ask questions and i will answer if something isnt clear
======== Added +++
after some research i found this http://us.php.net/manual/en/function.file.php
and also figured out that using C++ or other programming language will be easier.
Last edited: