Converting a complex series of objects to XML with XStream

I have a large collection of objects (lets call them "containers") each holding two ArrayLists and two doubles. What I need to do is to generate a XML-based report from this collection according to the following format:

<row> <ref> <db>DB-name</db> <value>DB-Id</value> </ref> <value> <no>0</no> <value>val1</value> </value> <value> <no>1</no> <value>val2</value> </value> <value> <no>2</no> <value>val3</value> </value> </row>

Here the value of DB-name is constant throughout, however the DB-Id.s are stored in the lists. values val1, val2 and val3 are calculated from the two doubles in the container object. What I need to do is to create a row-tag for each id stored in the lists, with the same values (as all the id.s in the container object share these values).

I have been looking examples at the XStream webpage but couldn't find a nice way to tackle the problems that apply to my situation here, instead got a bit more confused as to if what I want/need to do is achievable or do I have to write my own XMLWriter implementation...

Any ideas as to how I can achieve this?

Category:java Views:0 Time:2010-11-01
Tags: xml java xstream

Related post

  • Serializing Java objects to XML with XStream 2010-06-29

    The problem is that every time I execute the main method, the old content of a.xml is lost and is substituted with a new one. How to append content to the a.xml file without losing the previous information? import java.io.FileNotFoundException; impor

  • JAXB: Convert Javabean Object to XML all properties as XML attributes rather than XML elements (node) 2012-02-09

    Currently I'm working on converting object to XML, I notice all object properties are listed as XML elements (node) unless you use @XmlAttribute on a particular getter or setting Just wondering is there a way to automatically convert all object prope

  • What is the best way to convert a java object to xml with open source apis 2009-04-10

    I was wondering what the best or most widely used apis are to convert a java object to xml. I'm fairly new on the subject. Is there some sort of api call you can make to pass in an object and return xml? Or is it much more tedious where as you need t

  • Problem With \ When Converting object to XML 2010-10-02

    I have a problem when I convert an object to XML. The result is like <Entry From=\"08:46:07\" To=\"20:47:06\" TypeId=\"1\" /> and I want to remove the \ in the XML. How can I do this? --------------Solutions------------- Are those slashes actua

  • How to convert List of Object to XML doc using XStream 2010-11-02

    How to convert List of Object to XML doc using XStream ? and how to deserialize it back ? This is my xml <?xml version="1.0" encoding="UTF-8"?> <persons> <person> <fullname>Guilherme</fullname> <age>10</age>

  • Convert or cast object[] to xml document and retreive values from xml nodes 2011-03-06

    What is the most optimized code for converting an object[] to an xml document? In a function from a service the return type is object [] and the object returned contains a list of xml elements. So I need to convert this object[] to xml for data retri

  • convert object to xml 2011-03-14

    I need to convert an object to xml and have gone through few articles to do it. however, I am getting an error" Error generating an xml document. Make sure the source type is same as the destination type". Below is my code namespace XYZ { [Serializab

  • Convert Java object to XML 2011-05-11

    I am trying to convert a Java object inside of a Java library to an XML file. However, I got this problem: A a = new A(); // initializing for a JAXBContext jc = JAXBContext.newInstance("libraryA.A"); Marshaller marshaller = jc.createMarshaller(); mar

  • How to dynamically add attributes to an object and convert that object to xml 2011-07-01

    How to dynamically add attributes to an object and convert that object into xml in Flex/Actionscript? --------------Solutions------------- You must denote the object as dynamic, then you can add any properties you want. Then you can fall back on the

  • Problems converting from an object to XML in java 2011-09-14

    What I'm trying to do is to convert an object to xml, then use a String to transfer it via Web Service so another platform (.Net in this case) can read the xml and then deparse it into the same object. I've been reading this article: http://simple.so

  • Is there any possible way to convert XML::Twig object to XML::XPath object? 2011-10-19

    I'm using XML::XPath for a long time to parse xml, now the situation has come to modify the attribute value. xml is available in a file, it will be very similar to this. <AppName> <Action AllDay='1'StartRace='1'/> <StartPoint AM_PM='AM

  • Convert Scala object to XML 2011-12-02

    There are numerous Scala libraries to convert arbitrary objects to JSON and a few to convert JSON to XML, but I can't seem to find a nice way to convert arbitrary objects to XML. What's a good approach? --------------Solutions------------- I used sca

  • How can i store the ArrayList of complex objects into xml? 2012-01-15

    I have two classes which are having relations with each other as below. I have a list of ObjReal objects where the whole data is presented. I want to save the whole List into xml without losing the object relationships. I mean an object represented i

  • Convert Java complex object to Json 2011-11-30

    I need to convert the following Class: package comS309.traxz.data; import java.util.Collection; import org.json.JSONException; import org.json.JSONObject; public class ExerciseSession { public String DateCreated; public String TotalTime; public Strin

  • Convert form data to JS object with jQuery 2009-07-26

    How do I convert all elements of my form to a JS object? I'd like to have some way of automatically building a JS object from my form, without having to loop over each element. I do not want a string, as returned by $('#formid').serialize();, nor do

  • Serialize Object to XML in with specific format 2010-07-21

    Im trying to Serialize an object( a class in this case) with an specific fomat. I got something like this: <ns:pay xmlns:ns="http://example.uri.here"> <ns:Payment> <ns:customerKeyValue>5555</ns:customerKeyValue> <ns:bankCod

  • PHP Object as XML Document 2008-09-26

    What is the best way to take a given PHP object and serialize it as XML? I am looking at simple_xml and I have used it to parse XML into objects, but it isn't clear to me how it works the other way around. --------------Solutions------------- take a

  • Java object to XML schema 2008-11-04

    If you have a Java object and an XML schema (XSD), what is the best way to take that object and convert it into an xml file in line with the schema. The object and the schema do not know about each other (in that the java classes weren't created from

  • What Is The Best Place To Store An Object's XML/CSV/Other Representation 2009-01-04

    When an object has various formats (XML,CSV) it can be represented in, where should one store knowledge of those formats. Should the object have knowledge of how it's represented in XML (i.e. letting the object convert itself through some method on t

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.087 (s). 11 q(s)