Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - Text file to XML file [Thread Next] Re: Text file to XML fileTo: NULL Date: 8/2/2004 4:42:00 AM In article <rbuOc.8728$pc.461269@n...>, Rizwan <hussains@p...> wrote: % I have the following tasks : % 1) receive a flat text file which contains data and % 2) convert it into an XML I don't think there's any point in using specialised tools to create XML. Reading it is different. Use a parser to read it. Don't write your own parser unless you're interested in understanding all the ins and outs and getting them right, but creating XML is close to trivial. The things you need to be careful of: - character sets. You have to know what character set was used to encode your input data and either declare the XML file to use that data or convert it to UTF-8; - < and &. Replace them with < and &. Before you start, you ought to design the output format and document it either by writing a DTD, a w3c schema or a RELAX NG schema. This will be more work than creating the conversion program, but it will be helpful in ensuring the conversion is valid XML. There are some philosophical issues in the design. Should each record be represented by an empty element with a bunch of attributes, or by an element with a bunch of other elements containing CDATA for the data? Should each record be a `record' element, or should I go for interoperability by describing the type of record? Should I give my data a name space or is this too obvious a question and I just left it out of my example for the sake of brevity? Except for the last one, you seem to have resolved these issues in a satisfactory manner, so damn the torpedos and have fun. -- Patrick TJ McPhee East York Canada ptjm@i... | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
