How to create an XML text node with an empty string value (in Java)

后端 未结 7 1717
温柔的废话
温柔的废话 2020-12-16 16:00

I am using a Transform object to save my XML file but it seems to drop empty text nodes. Is there any way to create (and keep) a text node with an empty string

7条回答
  •  没有蜡笔的小新
    2020-12-16 16:56

    I've had a similar issue where when the XML was parsed back in, was treated as null when what I needed was so it would be parsed in as an empty string. I ended up working around this by adding an empty comment node to it so it ended up looking like this .

    Sorry if this doesn't directly answer the question but this is top answer on google so thought someone might find this useful.

提交回复
热议问题