Link to home
Start Free TrialLog in
Avatar of feliciayong
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"?><!DOCTYPE Pip3A4PurchaseOrderRequest SYSTEM "3A4_MS_V02_03_PurchaseOrderRequest.dtd"><Pip3A4PurchaseOrderRequest>
   <fromRole>
      <PartnerRoleDescription>
         <ContactInformation>
            <contactName>
               <FreeFormText>FE Global Electronics Pte Ltd</FreeFormText>
            </contactName>
            <EmailAddress>kh.loh@fe-electronics.com</EmailAddress>
            <facsimileNumber>
               <CommunicationsNumber/>
            </facsimileNumber>
            <telephoneNumber>
               <CommunicationsNumber/>
            </telephoneNumber>
         </ContactInformation>
         <GlobalPartnerRoleClassificationCode>Buyer</GlobalPartnerRoleClassificationCode>
         <PartnerDescription>
            <BusinessDescription>
               <GlobalBusinessIdentifier>595171083</GlobalBusinessIdentifier>
               <GlobalSupplyChainCode>Electronic Components</GlobalSupplyChainCode>
            </BusinessDescription>
            <GlobalPartnerClassificationCode>Manufacturer</GlobalPartnerClassificationCode>
         </PartnerDescription>
      </PartnerRoleDescription>
   </fromRole>
</Pip3A4PurchaseOrderRequest>
Avatar of Mayank S
Mayank S
Flag of India image

You can use this for creating XML files:

http://www.javaalmanac.com/egs/org.w3c.dom/pkg.html

Avatar of slyong
slyong

ASKER CERTIFIED SOLUTION
Avatar of mukundha_expert
mukundha_expert

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial