Solved

How to get Blank tags from XML using Oracle DOM Parser

Posted on 2004-09-13
5
258 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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

726 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