Filter out XML Contents


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Filter out XML Contents

  1. #1
    Join Date
    Jan 2006
    Posts
    9

    Create a new tag in XML

    I have the following java file(Customer.java).

    public class Customer
    {
    private String ID;
    private FirstName firstName;
    private MiddleName middleName;
    private LastName lastName;
    private String streetno;
    private String city;
    private String pin;
    private String phone;


    public FirstName getFirstName() {
    return firstName;
    }
    public void setFirstName(FirstName firstName) {
    this.firstName = firstName;
    }
    public String getID() {
    return ID;
    }
    public void setID(String id) {
    ID = id;
    }
    public LastName getLastName() {
    return lastName;
    }
    public void setLastName(LastName lastName) {
    this.lastName = lastName;
    }
    public MiddleName getMiddleName() {
    return middleName;
    }
    public void setMiddleName(MiddleName middleName) {
    this.middleName = middleName;
    }

    public String getStreetNo() {
    return streetno;
    }
    public void setStreetNo(String streetno) {
    this.streetno= streetno;
    }


    public String getCity() {
    return city;
    }
    public void setCity(String city) {
    this.city= city;
    }

    public String getPhone() {
    return phone;
    }
    public void setPhone(String phone) {
    this.phone= phone;
    }

    public String getPin() {
    return pin;
    }
    public void setPin(String pin) {
    this.pin= pin;
    }



    Using castor i have created an xml file(customer.xml) which has the following format.

    <?xml version="1.0" encoding="UTF-8" ?>
    - <customer ID="fbs0001">
    <FIRSTNAME>Fred</FIRSTNAME>
    <MIDDLENAME>B</MIDDLENAME>
    <LASTNAME>Scerbo</LASTNAME>
    <STREETNO>19</STREETNO>
    <CITY>Bangalore</CITY>
    <PIN>560054</PIN>
    <PHONE>9886582108</PHONE>
    </customer>


    I have used a mapping file to get this output.Is there a way where i can get the output xml in the following format without changing the Java object structure.If yes then please suggest how this can be done.

    <?xml version="1.0" encoding="UTF-8" ?>
    - <customer ID="fbs0001">
    <FIRSTNAME>Fred</FIRSTNAME>
    <MIDDLENAME>B</MIDDLENAME>
    <LASTNAME>Scerbo</LASTNAME>
    <ADDRESS>
    <STREETNO>19</STREETNO>
    <CITY>Bangalore</CITY>
    <PIN>560054</PIN>
    <PHONE>9886582108</PHONE>
    </ADDRESS>
    </customer>
    Last edited by tarun.arora; 01-09-2006 at 11:11 PM. Reason: Change in requirement

  2. #2
    Join Date
    Jun 2004
    Posts
    199
    That would be invalid XML. You will need a root element. Even if you do have a valid root xml, I am not sure you can easily do it with Castor, if at all. Try doing an additional XLT on the original output xml.

Similar Threads

  1. Try XML Junction
    By Tim in forum xml.announcements
    Replies: 0
    Last Post: 10-11-2001, 04:00 PM
  2. XML Startkabel Updates
    By xmlstartkabel in forum XML
    Replies: 0
    Last Post: 10-10-2001, 04:07 AM
  3. Data Junction Announces XML Junction 7.51
    By Tim Frost in forum xml.announcements
    Replies: 0
    Last Post: 04-02-2001, 10:53 AM
  4. Check out Turbo XML: Free trial download
    By Extensibility in forum web.announcements
    Replies: 0
    Last Post: 07-20-2000, 06:20 PM
  5. Check out Turbo XML
    By Sales in forum xml.announcements
    Replies: 0
    Last Post: 07-20-2000, 06:18 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center