I’m wondering if there is an accepted method to convert a tab delimited text file to XML, so that it can be imported in Adobe Flex. I would prefer to use PHP to achieve this.
Thanks
Edit:
The tab delimited text file I am looking to convert is in the format
Refnumber Location Name Age
123 North America Steve 32
And I am looking to convert to
<data>
<refnumber> 123 </refnumber>
<location> North America </location>
<name> Steve </name>
<age> 32 </age>
</data>
You can iterate the file line by line and write the contents with XMLWriter
XmlWriter Example (demo)
Using the XmlWriter has the added benefit that it will tell you when you are trying to write illegal content for the XML elements. If you know there is only valid data in your tsv file, you can also just use a template and write that to another file.
Template Example (demo)
Links
SplFileObject– The SplFileObject class offers an object oriented interface for a file.vsprintf— Return a formatted string from an array of arguments