I want to convert EDI Purchase Order document to XML or to a CSV
output. Can the XML parse a EDI document and emit a XML or CSV output
Please kindly advice how best it can be done.
I don't know EDI, but I recall that it predates XML; therefore I
strongly suspect that an XML parser won't like it. You need an EDI
parser (don't ask me where to find one) that creates a Perl structure,
then you can use XML::Simple (or something similar) to output that
structure as an XML document. This does not mean that the node names or
structure will be meaningful to another application, just that the
document will contain valid XML constructs.
I seriously doubt that CSV output will be useful, unless you just want
the actual items. I suspect that the EDI document will contain a great
deal of "wrapper" information, such as PO numbers, Ship-To and Bill-To
information, etc, that at best would require awkward formatting in a CSV
file.
My advice is to beg, borrow or steal an EDI module, unless you know
enough to write your own. Then you can try something like this:
use My::EDI:
arser;
use XML::Simple;
foreach (@ARGV) {
my $document = EDI_File_In($_);
print XML_Out($document);
}