This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes Suppress text nodes in output when empty Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Suppress text nodes in output when empty" Watch "Suppress text nodes in output when empty" New topic
Author

Suppress text nodes in output when empty

Ela Smith
Greenhorn

Joined: Aug 25, 2003
Posts: 1
Hello @all!
I try to output the nodes plus additional information of an xml-file.
Here is the code with wich I do it:

And that's part of the output I get:
infospace
NodeName: #text, NodeValue:
NodeName: subspace
NodeName: #text, NodeValue:
NodeName: EWGR
NodeName: #text, NodeValue:
NodeName: childNodes
NodeName: #text, NodeValue:
NodeName: childNode
NodeName: #text, NodeValue: C1
NodeName: #text, NodeValue:
NodeName: childNode
NodeName: #text, NodeValue: C2
NodeName: #text, NodeValue:
NodeName: childNode
NodeName: #text, NodeValue: C3
NodeName: #text, NodeValue:
NodeName: #text, NodeValue:
NodeName: #text, NodeValue:
NodeName: EWGR
NodeName: #text, NodeValue:
My question: How can I suppress the lines where the NodeName is #text and the NodeValue is empty?
First I tried this one:


Then I tried this one:

But nothing worked...
Can anybody help me with this problem, please?
Thanks a lot for your help in advance!
Ela
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
How about this:


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Suppress text nodes in output when empty
 
Similar Threads
How to get nested elements using DOM
xml and java
Why I can't retrieve records stored in a XMLFile correctly?
Parsing an xml file from an uri
xml parsing with dom