Solved

How to get Blank tags from XML using Oracle DOM Parser

Posted on 2004-09-13
5
257 Views
Last Modified: 2013-11-23
I am using Oracle DOM Parser to parser my XML.

I need to find out which tags are BLANK in the XML and then differ the processing for such tags . CAn anybody help
0
Comment
Question by:dibanu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 21

Expert Comment

by:MogalManic
ID: 12042589
For nodes that are blank node.getChildNodes()==null
For nodes that only contain whitespace:

isBlank=true;
NodeList nl=node.getChildNodes();
for(int i=0;i<nl.getLength();i++) {
  Node eachItem=nl.item(i);
  if (!eachItem instanceof TextElement) {
     isBlank=false;
     break;
  } else {
     if (eachItem.getNodeValue().trim().length>0) {
       isBlank=false;
       break;
     }
  }
}
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12045954
Not sure if i understand that code example although i think


>>if (eachItem.getNodeValue().trim().length>0) {


should be

if (eachItem.getNodeValue().trim().length()>0) {

You may want to add the blank nodes to a List so you know which ones to avoid

0
 
LVL 21

Accepted Solution

by:
MogalManic earned 125 total points
ID: 12046331
Sorry, didn't compile code.  Here is correct version:

        boolean isBlank=true;
        NodeList nl=node.getChildNodes();
        for(int i=0;i<nl.getLength();i++) {
            Node eachItem=nl.item(i);
            if (!(eachItem instanceof Text)) {
                isBlank=false;  //This node in the tree is NOT a leaf (i.e. it has children that are Element Nodes)
                break;
            } else {
                if (eachItem.getNodeValue().trim().length()>0) {
                    isBlank=false;  //This node has non-whitespace data as children
                    break;
                }
            }
           
        }
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This video teaches viewers about errors in exception handling.
Suggested Courses

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question