Jump to content

Creating xml files


StarGateSG-1
 Share

Recommended Posts

Add some elements around the sections of the text you want to extract separately, perhaps even group them in another element by some sort of criteria, add the XML prolog and possibly some encoding to it. If your text has one of the special entities, you should also mark it in CDATA. Save the file with XML extension and you're done.

Link to comment
Share on other sites

Sorry,I should have been more specific.I need some one to point me in the direction of source code, or tutorials to convert text files to xml files at the press of a button. I am writing a program for my school, which creates text files from our data system and I want to put them into xml files. Keep in mind I won;t be there to do it by hand. It must be automated.Any language would do, I would perfer something web based, but non would be fine.Thank you.

Link to comment
Share on other sites

Sure,the format is in fields. eg:123456789123456789123456789123456789firstname lastname age ###### Those arn't fields I would use but they are the most common, becasue this project is through the school, the data is private so It is hard to find the actuaclly field lengths I need, atm.Like that with space alotted for each section, I need a reference more than it done for me.Thank you.

Link to comment
Share on other sites

do you know PHP?that is what I would use, but that might just be that I don't know anything better :) .so anyway, look up the file_get_contents() function here: http://us3.php.net/manual/en/function.file-get-contents.phpopen your file with that, and have the text fields seperated with | or something else, then use explode(): http://us2.php.net/explodethen enter the xml tags in and save it using the fopen() fwrite() and fclose() statements. (google php fopen())LGEdit: if you need it more specific, I can do that too.

Link to comment
Share on other sites

If by VB you mean VBScript, it's a client side scripting language. It can't generate files, but I think it might be able to turn a text into XML and show it as one. Still, you need to reuse that XML data somewhere right? That's where VBScript fails.If you mean Visual Basic... well it could, but it's not web based technology, therefore inaccessable from a site.As far as I know, you could use VBScript on the server side with ASP(.NET?), so if PHP doesn't suit you but VB does, you should try ASP(.NET).Any other server side scripting language might also do the trick though. Cold Fusion, JSP, etc.

Link to comment
Share on other sites

OkI was looking into in Visual Basic, because I wnat to stay away from servers right now, I just don't enough and don't have time to learn. I am already using xsl to display the info, I just need get the data from a text file. I don't think a script is right for this program, I need it simple as I found out yesterday.

Link to comment
Share on other sites

VBScript will support something called (eurrgh!!) the "Scripting.FilesystemObject".If you create a new instance in vbscript of the above object (provided you are running IE to do the work), you will be able to read from the file using delimiters (e.g. a space character) to separate data items.You can then use a second instance to output to a new file and add in your xml tags.The most horrible thing about this is that you have to know when the data items start and end and what each data element contains.try looking at this link and see if it helps:msdn FileSystemObject referenceIf there is any way at all that you can change the output of the data to have better delimiters and write one "record" per line of data then I would suggest you do it - this will save you a lot of heartache when you convert the data.Hope this helps, give me some feedback if it doesn't. :).Dooberry

Link to comment
Share on other sites

Yeah,I forgot to mention that you will need an instance of the TextStreamObject object as well, but the reference for this won't be far away from the link I gave you, sorry about that.In the words of Joey Tribiani's agent

No harm, No Fooull!!
Have fun.Dooberry.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...