Title: RE: [dom4j-user] How to avoid trimming of spaces in text
Balaji,
 
I can't reproduce your problem. You say "when you get the element tag it displays ...".  Do you mean that serializing the document as text gives you this result?  If so, what mechanism do you use to output the XML as text? The inherited Node#asXML() method or the org.dom4j.io.XMLWriter class?  (I couldn't reproduce the problem with either of these.)
 
When I run the following snippet:
 
DocumentFactory df = DocumentFactory.getInstance();
Element parent = df.createElement(
"parent"
);
parent.addElement("LINE").addText(" MODELCNTCTR"
);
System.out.println(parent.element("LINE").asXML());

(or even with the last line as "new XMLWriter().write(parent.element("LINE"));")

I get the correct result "<LINE> MODELCNTCTR</LINE>".

--
knut

-----Original Message-----
From: Balaji Varatharaj [mailto:[EMAIL PROTECTED]
Sent: Mittwoch, 2. April 2003 20:52
To: Wannheden, Knut; [EMAIL PROTECTED]
Subject: RE: [dom4j-user] How to avoid trimming of spaces in text

Hi,
   I am using 1.3 version of Dom4j.
  Here is the part of code i am using.some values are harcoded here
 
    String elementName = "LINE";   
    String elementValue = " MODELCNTCTR";   
    ((Element)parentElement.addElement(elementName).addText(elementValue);
 
    When i use  the above code and get the element tag it displays  <LINE>MODELCNTCTR</LINE>   without any spaces
 
Thanks
Balaji
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]On Behalf Of Wannheden, Knut
Sent: Wednesday, April 02, 2003 9:58 AM
To: [EMAIL PROTECTED]
Subject: RE: [dom4j-user] How to avoid trimming of spaces in text

Balaji,

That should certainly not be the case.  Can you show some code which demonstrates the problem?  And what version of dom4j are you using?

Regards,

--
knut

> -----Original Message-----
> From: Balaji Varatharaj [mailto:[EMAIL PROTECTED]]
> Sent: Mittwoch, 2. April 2003 16:41
> To: [EMAIL PROTECTED]
> Subject: [dom4j-user] How to avoid trimming of spaces in text
>
>
> Hi ,
>       I am adding a text to an Element with the leading
> spaces..for example "
> command".But the space in front of " command" is trimmed
> while adding to an
> Element.
> So the final Element tag i am getting is <LINE>command</LINE>
> instead of
> <Line> command</LINE>
>
> How to add spaces in text that will be preserved in the Element?
> Any ideas?
>
>
> Thanks
> Balaji
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: ValueWeb:
> Dedicated Hosting for just $79/mo with 500 GB of bandwidth!
> No other company gives more support or power for your dedicated server
> http://click.atdmt.com/AFF/go/sdnxxaff00300020aff/direct/01/
> _______________________________________________
> dom4j-user mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/dom4j-user
>

Reply via email to