Many thanks to all that have helped me with the text file to xml conversion routine. I have pasted below the code.
I have one issue that I would be grateful for some help on. You can see that the | delimted file contains the property ref and the image as also shown below in the text file.
You will notice that the property ref may appear on more than one line but with a different image. This is because a property can have more than 1 internal pic. I am interested in upto 4.
I suppose it is what you would call transactional. There maybe more than 4 but I am only interested in upto the first 4 images.
What I need to do is scan the text file and create an xml output where we have the property ref then image1 through to image X.
an xml example would be
<properties>
<property>
<property_ref>abc123</property_ref>
<image1>image1.jpg</image1>
<image2>image2.jpg</image2>
<image3>image3.jpg</image3>
<image4>image4.jpg</image4>
</property>
</properties>
The code as it is at the moment
<?php
include("vars.php");
$fp=fopen($textfile2,'r');
$FileContents=fread($fp, filesize ($textfile2));
fclose($fp);
$fp=fopen($xml_output_dir.$xml_output,'w');
fclose($fp);
$FileData= explode("", $FileContents);
$output.="<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n";
$output.="<properties>\n";
for($i=0;$i<count($FileData);$i++)
{
$Data = explode("¦", $FileData[$i]);
for($c=0;$c<2;$c++)
{$Result[$c]=trim($Data[$c]); }
$c=0;
$image=$Result[1];
$conv_image=eregi_replace(",", " " , $image);
$len=strpos($conv_image," ");
$Result[1]=substr($conv_image,0,$len);
$output.=" <property>\n";
$output.=" <property_ref>{$Result[0]}</property_ref>\n";
$output.=" <internal>{$Result[1]}</internal>\n";
$output.=" </property>\n";
}
$output.="</properties>\n";
$fp=fopen($xml_output_dir.$xml_output,'w');
fwrite($fp,$output);
fclose($fp);
?>
Text file example
abc123 | image1.jpg ^
abc123 | image2.jpg ^
def456 | imagea.jpg ^
def456 | imageb.jpg ^
def456 | imagec.jpg ^
def456 | imaged.jpg ^