feliciayong
asked on
Use JAVA to convert tab delimited text file to xml
hi to any experts out there...
I have a tab-delimited text file "contents.txt" with the following contents :-
contents.txt
--------------
FE Global Electronics Pte Ltd kh.loh@fe-electronics.com 12345678 12345678 Buyer 595171083
Electronic Components Manufacturer
How to convert the text file to a xml file using java programming?
desired output of the xml file: -
<?xml version="1.0" encoding="UTF-8"?><!DOCTYP E Pip3A4PurchaseOrderRequest SYSTEM "3A4_MS_V02_03_PurchaseOrd erRequest. dtd"><Pip3 A4Purchase OrderReque st>
<fromRole>
<PartnerRoleDescription>
<ContactInformation>
<contactName>
<FreeFormText>FE Global Electronics Pte Ltd</FreeFormText>
</contactName>
<EmailAddress>kh.loh@fe-el ectronics. com</Email Address>
<facsimileNumber>
<CommunicationsNumber/>
</facsimileNumber>
<telephoneNumber>
<CommunicationsNumber/>
</telephoneNumber>
</ContactInformation>
<GlobalPartnerRoleClassifi cationCode >Buyer</Gl obalPartne rRoleClass ificationC ode>
<PartnerDescription>
<BusinessDescription>
<GlobalBusinessIdentifier> 595171083< /GlobalBus inessIdent ifier>
<GlobalSupplyChainCode>Ele ctronic Components</GlobalSupplyCh ainCode>
</BusinessDescription>
<GlobalPartnerClassificati onCode>Man ufacturer< /GlobalPar tnerClassi ficationCo de>
</PartnerDescription>
</PartnerRoleDescription>
</fromRole>
</Pip3A4PurchaseOrderReque st>
I have a tab-delimited text file "contents.txt" with the following contents :-
contents.txt
--------------
FE Global Electronics Pte Ltd kh.loh@fe-electronics.com 12345678 12345678 Buyer 595171083
Electronic Components Manufacturer
How to convert the text file to a xml file using java programming?
desired output of the xml file: -
<?xml version="1.0" encoding="UTF-8"?><!DOCTYP
<fromRole>
<PartnerRoleDescription>
<ContactInformation>
<contactName>
<FreeFormText>FE Global Electronics Pte Ltd</FreeFormText>
</contactName>
<EmailAddress>kh.loh@fe-el
<facsimileNumber>
<CommunicationsNumber/>
</facsimileNumber>
<telephoneNumber>
<CommunicationsNumber/>
</telephoneNumber>
</ContactInformation>
<GlobalPartnerRoleClassifi
<PartnerDescription>
<BusinessDescription>
<GlobalBusinessIdentifier>
<GlobalSupplyChainCode>Ele
</BusinessDescription>
<GlobalPartnerClassificati
</PartnerDescription>
</PartnerRoleDescription>
</fromRole>
</Pip3A4PurchaseOrderReque
Hi Sorry for the lazy solution. There is an example here:
data: http://www.ibiblio.org/xml/slides/sd2000west/xmlandjava/38.html
program: http://www.ibiblio.org/xml/slides/sd2000west/xmlandjava/39.html
data: http://www.ibiblio.org/xml/slides/sd2000west/xmlandjava/38.html
program: http://www.ibiblio.org/xml/slides/sd2000west/xmlandjava/39.html
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://www.javaalmanac.com/egs/org.w3c.dom/pkg.html