Code:
file.txt

{NAME}
name1
{DATA}
data1 contents
{DATE}
20080923
{TIMESTAMP}
{STORY}
story here
{NAME}
name2
{DATA}
data2 contents
{DATE}
20080924
{TIMESTAMP}
898908
{STORY}
story here

How to convert to xml format from the above file and create a new xml file for each start of '{NAME}' and filename should be name1.xml.

The file name1.xml should contain like this
Code:
<NAME>name1</NAME>
<DATA>data1 contents</DATA>
<DATE>20080923<DATE>
<TIMESTAMP></TIMESTAMP>
<STORY>story here</STORY>

the file name2.xml should contain like this
<NAME>name2</NAME>
<DATA>data2 contents</DATA>
<DATE>20080924<DATE>
<TIMESTAMP>898908</TIMESTAMP>
<STORY>story here</STORY>
Code:
<?php
$array_names = array('{DATA}','{DATE}','{TIMESTAMP}','{STORY}');
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
$myFile = "file.txt";
$fh = fopen($myFile, 'r');

//Here I have to find the string

 ?>