Dyanmic XML Tag name

View: New views
2 Messages — Rating Filter:   Alert me  

Dyanmic XML Tag name

by Donzil Pinto :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

Hi

 

We have been using Simple for XML serialization.

In one of our requirements, we need to create an xml file of the data fetched from a table.

 

For e.g.

A table with name “EMP_DET” has 3 columns (Name, Age, Designation).

 

The resulting xml file should be as follows

<row>

                <Name>John Doe</Name>

                <Age>31</Age>

                <Designation>Manager</Designation>

</row>

….

 

On using

 

@ElementMap(inline=true, attribute=false)

private Map<String, String> Columns;

 

We are getting the output as follows

<row>

                <entry>

                <String>Name</ String >

                < String >John Doe</ String >

</entry>

                <entry>

                <String>Age</ String >

                < String >31</ String >

</entry>

                <entry>

                <String> Designation </ String >

                < String > Manager </ String >

</entry>

</row>

….

 

Appreciate if you can let us know of any approach that will help to get the desired XML output.

 

Regards

______________________________________________________________________________________

Donzil Pinto | Sr. Technical Architect – Products & Technology
S Y S T I M E | Office: +91 22 2778 3100: Extn 5345 | Mobile: +91 9833 204935
Office Board: +91 22 2778 3100 | Fax: +91 22 27782291
Email: dpinto@... | Website: www.SYSTIME.net

 

cid:image003.jpg@01C96CB9.73C66060
   Please click here for the Confidentiality Statement.

______________________________________________________________________________________

 



------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Simple-support mailing list
Simple-support@...
https://lists.sourceforge.net/lists/listinfo/simple-support

Re: Dyanmic XML Tag name

by Niall Gallagher-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
Hi,
 
Ya, you can do this
 
public class MyEntry implements Entry{
@Element String name
@Element int age;
@Element String designation;
public String getName() {
   return name;
}
}
 
Then annotate like so.
 
@ElementList(entry="row", inline = true)
public Dictionary<Entry> list
The org.simpleframework.xml.util.Dictionary object is a list that can get entry object using the entry name, via getEntry. Its like a map. If this is not suitable. Then just use any collection of your choice. And provide a typed object as the entry. This will give you the desired XML.
 
Niall

--- On Wed, 10/14/09, Donzil Pinto <dpinto@...> wrote:

From: Donzil Pinto <dpinto@...>
Subject: [Simple-support] Dyanmic XML Tag name
To: simple-support@...
Date: Wednesday, October 14, 2009, 6:11 AM

Hi

 

We have been using Simple for XML serialization.

In one of our requirements, we need to create an xml file of the data fetched from a table.

 

For e.g.

A table with name “EMP_DET” has 3 columns (Name, Age, Designation).

 

The resulting xml file should be as follows

<row>

                <Name>John Doe</Name>

                <Age>31</Age>

                <Designation>Manager</Designation>

</row>

….

 

On using

 

@ElementMap(inline=true, attribute=false)

private Map<String, String> Columns;

 

We are getting the output as follows

<row>

                <entry>

                <String>Name</ String >

                < String >John Doe</ String >

</entry>

                <entry>

                <String>Age</ String >

                < String >31</ String >

</entry>

                <entry>

                <String> Designation </ String >

                < String > Manager </ String >

</entry>

</row>

….

 

Appreciate if you can let us know of any approach that will help to get the desired XML output.

 

Regards

______________________________________________________________________________________

Donzil Pinto | Sr. Technical Architect – Products & Technology
S Y S T I M E | Office: +91 22 2778 3100: Extn 5345 | Mobile: +91 9833 204935
Office Board: +91 22 2778 3100 | Fax: +91 22 27782291
Email: dpinto@... | Website: www.SYSTIME.net

 

cid:image003.jpg@01C96CB9.73C66060
   Please click here for the Confidentiality Statement.

______________________________________________________________________________________

 
-----Inline Attachment Follows-----

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference

-----Inline Attachment Follows-----

_______________________________________________
Simple-support mailing list
Simple-support@...
https://lists.sourceforge.net/lists/listinfo/simple-support



------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Simple-support mailing list
Simple-support@...
https://lists.sourceforge.net/lists/listinfo/simple-support