Results 1 to 2 of 2
- 11-15-2009, 04:10 AM #1
Member
- Join Date
- Oct 2009
- Posts
- 5
- Rep Power
- 0
Translating an XML with the DOM ParserAPI
Hello experts,
Here is what i am trying to achieve, I have a source XML which i need to translate it to a target xml with a different format/ structure as shown below:
Now the plan is to do this using Java, I do know of 2 APIs SAX and DOM,
I'd like to implement this using a DOM parser(eazier)
I would appreciate any guidance from anyone who's got some expertise on this:
Requirement:
Source XML Structure:
-The "summary" has details about a manager.
-A manager may either have a Distributor directory under him - If he has a distributor under him , that distributor will always have a seller assigned to him.
- A manager can have a Seller directly assigned under him.
Java Code:<RequestBody> <Summary> <ManagerName>Keith</ManagerName> <ManagerID>K09090</ManagerID> <Distributer>Raymond</Distributer> <DistributerID>R87877</DistributerID> <Seller>Alex</Seller> <SellerID>A9876</SellerID> </Summary> <Summary> <ManagerName>Keith</ManagerName> <ManagerID>K09090</ManagerID> <Distributer>Robert</Distributer> <DistributerID>R11111</DistributerID> <Seller>Blake</Seller> <SellerID>B09976</SellerID> </Summary> <Summary> <ManagerName>Keith</ManagerName> <ManagerID>K09090</ManagerID> <Seller>Marie</Seller> <SellerID>M87656</SellerID> </Summary> <Summary> <ManagerName>John</ManagerName> <ManagerID>J97654</ManagerID> <Seller>Charlie</Seller> <SellerID>C98765</SellerID> </Summary> <Summary> <ManagerName>John</ManagerName> <ManagerID>J97654</ManagerID> <Seller>Drew</Seller> <SellerID>D98455</SellerID> </Summary> </RequestBody>
And here is the target XML structure I need to Map to:
I would really appreciate any leads or any help on this as i haven't implemented this.Java Code:<ResponseBody> <ManagerEntity> <ManagerName>Keith</ManagerName> <ManagerID>K09090</ManagerID> <Distributer> <DistributerName>Raymond</DistributerName> <DistributerID>R87877</DistributerID> <Seller> <SellerName>Alex</SellerName> <SellerID>A9876</SellerID> </Seller> </Distributer> <Distributer> <DistributerName>Robert</DistributerName> <DistributerID>R11111</DistributerID> <Seller> <SellerName>Blake</SellerName> <SellerID>B09976</SellerID> </Seller> </Distributer> <Seller> <SellerName>Marie</SellerName> <SellerID>M87656</SellerID> </Seller> </ManagerEntity> <ManagerEntity> <ManagerName>John</ManagerName> <ManagerID>J97654</ManagerID> <Seller> <SellerName>Charlie</SellerName> <SellerID>C98765</SellerID> </Seller> <Seller> <SellerName>Drew</SellerName> <SellerID>D98455</SellerID> </Seller> </ManagerEntity> </ResponseBody>
Thanks
- 11-16-2009, 11:19 AM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Similar Threads
-
Translating Pascal into java
By willemjav in forum Advanced JavaReplies: 120Last Post: 08-15-2008, 11:26 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks