Announcement Announcement Module
Collapse
No announcement yet.
Removing List name from the XML output Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Removing List name from the XML output

    Hi,

    I am writing to an XML file. I have my domain structure as below:

    Code:
    public class BankData {
    
        List<Bank> bankList;
    
        public List<Bank> getBankList() {
            return bankList;
        }
    
        public void setBankList(List<Bank> bankList) {
            this.bankList = bankList;
        }
    }

    The output i am getting is as below:
    Code:
    <BankData>
         <bankList>
              <Bank>
                   <ibanCode>xxx</ibanCode> 
                   <name>xxx</name> 
                   <swiftCode>xxx</swiftCode> 
                   <accountNumber>xxx</accountNumber> 
             </Bank>
              <Bank>
                   <ibanCode>xxx</ibanCode> 
                   <name>xxx</name> 
                   <swiftCode>xxx</swiftCode> 
                   <accountNumber>xxx</accountNumber> 
              </Bank>
              <Bank>
                   <ibanCode>xxx</ibanCode> 
                   <name>xxx</name> 
                   <swiftCode>xxx</swiftCode> 
                   <accountNumber>xxx</accountNumber> 
              </Bank>
         </bankList>
    </BankData>
    The output i need is below (without the List name <bankList>):
    Code:
    <BankData>
             <Bank>
                   <ibanCode>xxx</ibanCode> 
                   <name>xxx</name> 
                   <swiftCode>xxx</swiftCode> 
                   <accountNumber>xxx</accountNumber> 
             </Bank>
              <Bank>
                   <ibanCode>xxx</ibanCode> 
                   <name>xxx</name> 
                   <swiftCode>xxx</swiftCode> 
                   <accountNumber>xxx</accountNumber> 
              </Bank>
              <Bank>
                   <ibanCode>xxx</ibanCode> 
                   <name>xxx</name> 
                   <swiftCode>xxx</swiftCode> 
                   <accountNumber>xxx</accountNumber> 
              </Bank>
    </BankData>
    Please guide me how can i remove the List name (<bankList>) from the output?

  • #2
    I tried

    Code:
    marshaller.addImplicitCollection(“bankList”, BankData.class);
    It worked.

    Comment

    Working...
    X