Hi Lavina,

If you want to work with arbitrary XML elements JiBX is probably not the 
best approach. JiBX expects to be able to relate element names to 
particular classes or values, which is the basis of data binding. A 
simple document object model, such as DOM, dom4j, JDOM, or XOM, will let 
you read any XML document without restriction, and you can then get the 
element name and value information out of the document model.

If you are mainly using XML where the element names correspond to 
particular objects, and just have this type of structure for part of 
your documents, you could write a custom marshaller/unmarshaller for 
this purpose. When marshalling this would just go through all the 
entries in a supplied HashMap and write them to the output document, 
using the key as the element name and the value as the content. When 
unmarshalling it'd just reverse this, reading the elements and content 
and storing into the HashMap. There are no examples that handle exactly 
this case, but you can see 
http://jibx.sourceforge.net/tutorial/binding-custom.html#marunmar for an 
example of custom marshaller/unmarshaller code.

  - Dennis

Dennis M. Sosnoski
SOA, Web Services, and XML
Training and Consulting
http://www.sosnoski.com - http://www.sosnoski.co.nz
Seattle, WA +1-425-296-6194 - Wellington, NZ +64-4-298-6117



Lavina Pereira wrote:
> Hi,
>
> My xml is in the following structure. I am trying to
> write the unmarshalling code to convert the xml into
> the data object...Can someone please help.
>
> XML:- 
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <note>
> <to>Tove</to>
> <from>Jani</from>
> <heading>Reminder</heading>
> <body>Don't forget me this weekend!</body>
> </note>
>
> Since the above xml elements and its values are not
> fixed, but dynamic, i need to store them as key and
> value pairs in a HashMap..Therefore my Java Class
> structure is as below:
>
> class TestHashMapper extends ...
> {
>     HashMap hMap = new HashMap();
> }
>
> Thanks,
> Lavi.
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 
>
>
> -------------------------------------------------------
> All the advantages of Linux Managed Hosting--Without the Cost and Risk!
> Fully trained technicians. The highest number of Red Hat certifications in
> the hosting industry. Fanatical Support. Click to learn more
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
> _______________________________________________
> jibx-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/jibx-users
>
>   


_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to