Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Need help converting a multi entity flat file into XML

0 views
Skip to first unread message

Shikari Shambu

unread,
Jul 1, 2009, 5:04:50 PM7/1/09
to

I have a legacy system that outputs a billing file where each data element
has a specific length. The billing file has multiple information

1. Customer billing information
2. Customer shipping information
3. Order information (#, date, totals etc...)
4. Order line items (item#, qty, unit price, line total)

Up until item 3 - it is fixed length. Since an order can have one or more
line items the overall length of the record will vary. The order line itself
will be fixed size that may repeat itself

I need help in figuring out how to transform this into XML. I have come
across examples of flat file to xml conversions where the entire record is
fixed length.

Any help or pointers to a solution is appreciated. Please note I do not have
BizTalk or similar products

Thanks

Martin Honnen

unread,
Jul 2, 2009, 7:43:42 AM7/2/09
to

Shikari Shambu wrote:
> I have a legacy system that outputs a billing file where each data
> element has a specific length. The billing file has multiple information
>
> 1. Customer billing information
> 2. Customer shipping information
> 3. Order information (#, date, totals etc...)
> 4. Order line items (item#, qty, unit price, line total)
>
> Up until item 3 - it is fixed length. Since an order can have one or
> more line items the overall length of the record will vary. The order
> line itself will be fixed size that may repeat itself
>
> I need help in figuring out how to transform this into XML. I have come
> across examples of flat file to xml conversions where the entire record
> is fixed length.

With the .NET framework using regular expression matching might help to
identify items in that flat file. To create XML you can use XmlWriter or
XmlDocument or (in .NET 3.5) LINQ to XML.


--

Martin Honnen --- MVP XML
http://msmvps.com/blogs/martin_honnen/

Shikari Shambu

unread,
Jul 2, 2009, 9:53:41 AM7/2/09
to

Martin,
Thanks for the input. I guess I forgot to mention that the attributes
are position based I.e. first 20 chars= customer first name 21st= middle
initial 22-42= last name etc... I am not sure if RegEx can help here. If you
have examples I would look to take a look.

Thanks

"Martin Honnen" <maho...@yahoo.de> wrote in message
news:O3d7cpw#JHA....@TK2MSFTNGP05.phx.gbl...

Martin Honnen

unread,
Jul 2, 2009, 10:10:18 AM7/2/09
to

Shikari Shambu wrote:

> Thanks for the input. I guess I forgot to mention that the attributes
> are position based I.e. first 20 chars= customer first name 21st= middle
> initial 22-42= last name etc... I am not sure if RegEx can help here. If
> you have examples I would look to take a look.

Regex pattern = @"^(?<fname>.{20})(?<mname>.)(?<lname>.{20})$";
is a regular expression capturing the first twenty characters in a group
named fname, then one character in a group named mname, then twenty
characters in a group named lname. So that way you can easily extract
the portions of the input string.
See http://msdn.microsoft.com/en-us/library/30wbz966.aspx or your local
MSDN library installation on how to use the .NET regular expression classes.

0 new messages