|
-
Mar 1st, 2012, 07:52 AM
#1
Thread Starter
Hyperactive Member
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
-
Mar 1st, 2012, 08:32 AM
#2
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|