You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Marc DEXET <Ma...@dsi.cnrs.fr> on 2005/01/28 18:07:08 UTC
RE : RE : [betwixt - dom4j] How to get a dom4j XML element from B
eanWr iter
Now I get a new problem :
If I set :
beanWriter.getXMLIntrospector().setAttributesForPrimitives(true);
I haven't element ( i.e. is null !)
I quote back the source :
-----------------------------
public static void main(String[] strings) throws IOException,
SAXException, IntrospectionException {
SAXContentHandler h = new SAXContentHandler(new
DOMDocumentFactory());
SAXBeanWriter beanWriter = new SAXBeanWriter(h);
beanWriter.getXMLIntrospector().setAttributesForPrimitives(true);
beanWriter.write( new PersonBean("Paul",22));
Element el = h.getDocument().getRootElement();
System.out.println(el.asXML());
}
What's wrong ?
Marc DEXET wrote:
> Thank for all folks, I get the answer !
>
> You have to use org.dom4j.io.SAXContentHandler.SAXContentHandler(
> org.dom4j.dom.DOMDocumentFactory ) constructor;
>
> Marc DEXET wrote:
>> Hello guys
>> I would to get a dom4j xmlElement from a BeanWriter.
>> A use SAXBeanWriter and dom4j SAXContenetHandler but I get a strange
>> result
>>>
>> <person id="1">
>> Paul<name/>
>> 22<age/>
>> </person>
>>
>> instead of
>>
>> <person>
>> <name>Paul</name>
>> <age>22</age>
>> </person>
>>
>> Have somebody an idea ?
--
Marc DeXeT
BEST - DSI Meudon
01.45.07.51.56
marc.dexet@dsi.cnrs.fr