users@jaxb.java.net

Re: Incorrect Marshalling Of Object

From: Wolfgang Laun <wolfgang.laun_at_gmail.com>
Date: Wed, 23 Dec 2009 09:53:17 +0100

To marshal a bean from a POJO class Foo you don't need to create a Document.

Assuming that the tag of your document should be "root", and that you have
method wrap from
https://jaxb.dev.java.net/tutorial/section_4_5-Calling-marshal.html#Calling%20marshal
all you have to do is:

JAXBContext jc = JAXBContext.newInstance( PACKAGE );
Marshaller m = jc.createMarshaller();
Foo foo = new Foo();
// ... foo.setAttr( "foo's attribute" ); ...
JAXBElement<Foo> jbe = wrap( "", "root", foo );
m.marshal( jbe, System.out );

-W

On Wed, Dec 23, 2009 at 5:27 AM, Sam Khan <samkhanski_at_yahoo.com> wrote:

>
> Hi,
>
> I'm attempting to marshall a POJO but am getting unwanted information in
> the
> outputted xml:
>
> <?xml version="1.0" encoding="utf-8"?>
> <#document>
> <Request/>
> </#document>
>
> Can anyone shed any light on why the '<#document>' tag is present in the
> output? I do see '#document' as the value of the name property of the
> Document.java object (created using DocumentBuilderFactory.java).
> Any idea what I need to do to make that value disappear in the xml output?
>
> Thanks,
> Sam
> --
> View this message in context:
> http://old.nabble.com/Incorrect-Marshalling-Of-Object-tp26897603p26897603.html
> Sent from the java.net - jaxb users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>