usr/src/java/util/org/opensolaris/os/vp/util/misc/XMLUtil.java
changeset 685 767674b0a2fb
parent 219 57841c113efe
equal deleted inserted replaced
684:f7b1d1fbdb8e 685:767674b0a2fb
    18  *
    18  *
    19  * CDDL HEADER END
    19  * CDDL HEADER END
    20  */
    20  */
    21 
    21 
    22 /*
    22 /*
    23  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
    23  * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
    24  * Use is subject to license terms.
       
    25  */
    24  */
    26 
    25 
    27 package org.opensolaris.os.vp.util.misc;
    26 package org.opensolaris.os.vp.util.misc;
    28 
    27 
    29 import java.util.NoSuchElementException;
    28 import java.util.NoSuchElementException;
    30 import org.w3c.dom.*;
    29 import org.w3c.dom.*;
    31 
    30 
    32 public class XMLUtil {
    31 public class XMLUtil {
    33     public static String getTextContent(Element element) {
    32     public static String getTextContent(Element element) {
    34 	StringBuffer buffer = new StringBuffer();
    33 	StringBuilder buffer = new StringBuilder();
    35 
    34 
    36 	element.normalize();
    35 	element.normalize();
    37 	NodeList children = element.getChildNodes();
    36 	NodeList children = element.getChildNodes();
    38 	for (int i = 0, n = children.getLength(); i < n; i++) {
    37 	for (int i = 0, n = children.getLength(); i < n; i++) {
    39 	    Node child = children.item(i);
    38 	    Node child = children.item(i);
    44 
    43 
    45 	return buffer.toString().trim();
    44 	return buffer.toString().trim();
    46     }
    45     }
    47 
    46 
    48     public static String getFullPath(Node node) {
    47     public static String getFullPath(Node node) {
    49 	StringBuffer buffer = new StringBuffer();
    48 	StringBuilder buffer = new StringBuilder();
    50 	while (node != null) {
    49 	while (node != null) {
    51 	    buffer.insert(0, node.getNodeName());
    50 	    buffer.insert(0, node.getNodeName());
    52 	    char separator = '/';
    51 	    char separator = '/';
    53 	    if (node instanceof Attr) {
    52 	    if (node instanceof Attr) {
    54 		separator = '@';
    53 		separator = '@';