Hi, I didn't really understand how that's going to help.

I am more concerned in preserving the empty text node when I serialize to e.g. a file... not so much the parsing.


Any one else have any ideas? Are blank text nodes like that invalid XML or something?



On Dec 11, 2008, at 11:53 AM, ravika...@gmail.com wrote:

Hi Lan,

I think we can Implement by LSParser Interface. 
http://java.sun.com/j2se/1.5.0/docs/api/org/w3c/dom/ls/LSParser.html
this link may help you.

Regards,
Ravikanth

On Thu, Dec 11, 2008 at 7:36 PM, Ian Hummel <hum...@parityinc.net> wrote:
Hi everyone,

I need to create XML that looks like this whenever the value of "tag" is "" (the empty string):

<root>
        <tag></tag>
</root>

I've tried the following:

DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document d = db.newDocument();
Element root = d.createElement("root");
Element tag = d.createElement("tag");
d.appendChild(root);
root.appendChild(tag);
Text text = d.createTextNode("\t");
tag.appendChild(text);


but I always end up with XML like this:

<root>
        <tag/>
</root>


Is there a way to force empty text nodes to get "denormalized" ?

Thanks,

Ian.



--
Ravikanth

Reply via email to