Java XML Node Value Check isWhitespaceNode(Node t)

Here you can find the source of isWhitespaceNode(Node t)

Description

is Whitespace Node

License

Apache License

Declaration

public static boolean isWhitespaceNode(Node t) 

Method Source Code

//package com.java2s;
/*//  w w  w.ja  va2  s.  c  o  m
 * Copyright 2003-2016 MarkLogic Corporation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import org.w3c.dom.Node;

public class Main {
    public static boolean isWhitespaceNode(Node t) {
        if (t.getNodeType() == org.w3c.dom.Node.TEXT_NODE) {
            String val = t.getNodeValue();
            return val.trim().length() == 0;
        } else
            return false;
    }
}

Related

  1. isText(Node node)
  2. isValidNode(Node node, String name)
  3. isWhiteSpace(Node node)
  4. isWhitespace(Node node)
  5. isWhitespaceNode(Node n)