Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Converting textfile to XML

  • 13-10-2004 9:52am
    #1
    Moderators, Society & Culture Moderators Posts: 2,688 Mod ✭✭✭✭


    Im working on a project where the client wants to convert text files to XML and then encrypt and email them to a specified address.

    Technology will be either PERL or C# (preferably c# because thats primarily the language i develop in, im not familiar with PERL at all though.)

    Steps involved are:

    1. Convert from input text file to XML

    2. Encrypt XML file

    3. Email Encrypted XML file.

    2 and 3 i have possible solutions for, however 1. the text to XML conversion is a bit frustrating...

    any suggestions pointers or solutions are much appreciated.

    cheers.


Comments

  • Registered Users, Registered Users 2 Posts: 15,443 ✭✭✭✭bonkey


    What do you mean by "convert text to XML".

    What type of text?

    If its structured, you can probably XSLT it directly into proper XML. Alternately, you can parse it any which way you like (i.e. read it in, parse in memory), and then generate & write the ensuing XML using an XMLWriter or something like that.

    If its not structured, then its kinda impossible to move it to XML.....

    Should be easy enough to do, TBH...

    jc


  • Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭Hobbes


    bonkey wrote:
    If its not structured, then its kinda impossible to move it to XML.....

    Well thats not entirely true. There is a document based XML layout (eg. XHTML uses it afair). I can't remember the name offhand though, which is pretty depressing for me because I am actually studying for the XML exam at the moment. :o

    Btw, this looks like a school project. So hows about posting what you are planning so far or what parts you have a problem with? Which is beyond your reach of google.

    1. http://www.cpan.org and look for XML::RSS
    2. http://www.w3.org/Encryption/2001/
    3. http://www.codeproject.com/csharp/sendmailcsharp.asp

    Bare in mind if it is a school project that just ripping off other peoples code is a no no.


  • Closed Accounts Posts: 324 ✭✭madramor


    do you have dtd or schema for the xml you want to create

    if not, technically
    <xml>
    <dump>
    text slightly cleaned up
    </dump>
    </xml>
    is an xml file

    pearl has strong pattern matching so that is why you where probably,directed
    towards it


  • Closed Accounts Posts: 17,208 ✭✭✭✭aidan_walsh


    There is one more thing to consider, and thats whether he's talking about txt files, doc files, RTF files, etc. Because if he means anything bar the first, the XML could be to map the formatting.

    edit: Although the more I look at it, the less likely it seems, its still quite possible.


  • Moderators, Society & Culture Moderators Posts: 9,689 Mod ✭✭✭✭stevenmu


    Haven't looked into XML much yet, but I think a C# dataset has methods for dumping to an XML file. If your text file is structured it should be easy enough to setup a datatable with the right schema, write a little ditty to pull in the text file and then just dump it out to an xml file.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 3,312 ✭✭✭mr_angry


    Eclipse has an XML parsing library you can get called Xerces which has some nifty functions for parsing and generating XML files. JAXP also provides a great API for parsing streams, DOM trees, etc.

    Still, as mentioned above, unless the original text is structured already in some way, its still going to be messy.


  • Closed Accounts Posts: 324 ✭✭madramor


    xerces is an apache library


  • Registered Users, Registered Users 2 Posts: 1,865 ✭✭✭Syth


    You would definity need to have the original file in some sort of ordered fashion. If the original file was generated my a programme you're probaby grand. Perl would be ideal for converting text. It's fantastic for text processing. Some people have mentioned XSLT or the like. That would only work if the original was an XML file. If so then write some kind of XSLT stylesheet and use xmlto to convert it form one kind of XML to another. If however it's not an XML file then use perl, it's perfect.


  • Registered Users, Registered Users 2 Posts: 932 ✭✭✭yossarin


    might be overkill but if you're searching for particular patterns in large text files you could do worse than using regular expressions


Advertisement