Results 1 to 2 of 2

Thread: Best Way to convert to xml?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2005
    Posts
    323

    Best Way to convert to xml?

    Hi all,

    I have a text file that contains multiple record types with variable length records based on the record type. Each record has its own field definition.

    So it looks something like this (only WAY bigger)

    A123 45678 AB CDEF
    BXYXABCDEF
    C123456789 123456789
    etc.


    I also have a xsd file with the xml layout I need to map the text to.

    I could simply build a text file mapping each individual field to the approprite element as I read through the text file, but there's got to be an easier way.

    In the past I would have used something like an EDI translator to do all the work for me, but in this case I have no such tool available.

    Any ideas or links that might be helpful to keep me from having to loop through every single field and create every single xml element or am I stuck doing it this way?

    Thanks in advance,
    J

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Best Way to convert to xml?

    Depending on the desired outcome... I'd write a class to hold the data, then mark it as serializable, add the xml markup attributeds to each property, then use XML Serialization to generate the XML from the class... since you have an XSD, you know what the desired outcome of the XML needs to be, from there you reverse engineer what the class(es) should look like, then write an import process that reads the file and creates the objects as needed. Dump them into a custom collection, serialize it, bam! Bob's your uncle.

    I've done that successfully (a number of years ago two lifetimes ago) as a EDI<-> XML go between and as an interface to BizTalk/.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width