org.w3c.dom.NodeList Java Examples

The following examples show how to use org.w3c.dom.NodeList. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FileFormatWriter.java    From healthcare-dicom-dicomweb-adapter with Apache License 2.0 8 votes vote down vote up
private int computeLength(IIOMetadataNode root) {
    NodeList list = root.getChildNodes();
    int length = 0;
    for (int i = 0; i < list.getLength(); i++) {
        IIOMetadataNode node = (IIOMetadataNode)list.item(i);
        String name = node.getNodeName();

        if (format.isLeaf(name))
            length += new Integer((String)Box.getAttribute(node, "Length")).intValue();
        else
            length += computeLength(node);

    }

    return length + (root.getNodeName().startsWith("JPEG2000") ? 8 : 0) ;
}
 
Example #2
Source File: MyBatisGeneratorConfigurationParser.java    From mapper-generator-javafx with Apache License 2.0 6 votes vote down vote up
protected void parseJavaModelGenerator(Context context, Node node) {
    JavaModelGeneratorConfiguration javaModelGeneratorConfiguration = new JavaModelGeneratorConfiguration();

    context
            .setJavaModelGeneratorConfiguration(javaModelGeneratorConfiguration);

    Properties attributes = parseAttributes(node);
    String targetPackage = attributes.getProperty("targetPackage");
    String targetProject = attributes.getProperty("targetProject");

    javaModelGeneratorConfiguration.setTargetPackage(targetPackage);
    javaModelGeneratorConfiguration.setTargetProject(targetProject);

    NodeList nodeList = node.getChildNodes();
    for (int i = 0; i < nodeList.getLength(); i++) {
        Node childNode = nodeList.item(i);

        if (childNode.getNodeType() != Node.ELEMENT_NODE) {
            continue;
        }

        if ("property".equals(childNode.getNodeName())) {
            parseProperty(javaModelGeneratorConfiguration, childNode);
        }
    }
}
 
Example #3
Source File: MicroIntegratorBaseUtils.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
public static void resolveLeafNodeValue(Node node) {

        if (node != null) {
            Element element = (Element) node;
            NodeList childNodeList = element.getChildNodes();
            for (int j = 0; j < childNodeList.getLength(); j++) {
                Node chileNode = childNodeList.item(j);
                if (!chileNode.hasChildNodes()) {
                    String nodeValue = resolveSystemProperty(chileNode.getTextContent());
                    childNodeList.item(j).setTextContent(nodeValue);
                } else {
                    resolveLeafNodeValue(chileNode);
                }
            }
        }
    }
 
Example #4
Source File: KeyInfo.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Method itemUnknownElement
 *
 * @param i index
 * @return the element number of the unknown elements
 */
public Element itemUnknownElement(int i) {
    NodeList nl = this.constructionElement.getChildNodes();
    int res = 0;

    for (int j = 0; j < nl.getLength(); j++) {
        Node current = nl.item(j);

        /**
         * $todo$ using this method, we don't see unknown Elements
         *  from Signature NS; revisit
         */
        if ((current.getNodeType() == Node.ELEMENT_NODE)
            && current.getNamespaceURI().equals(Constants.SignatureSpecNS)) {
            res++;

            if (res == i) {
                return (Element) current;
            }
        }
    }

    return null;
}
 
Example #5
Source File: XMLTableSerializer.java    From MogwaiERDesignerNG with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void deserialize(Model aModel, Document aDocument) {
	// Now, parse tables
	NodeList theElements = aDocument.getElementsByTagName(TABLE);
	for (int i = 0; i < theElements.getLength(); i++) {
		Element theElement = (Element) theElements.item(i);

		Table theTable = new Table();
		theTable.setOwner(aModel);
		deserializeProperties(theElement, theTable);

		deserializeCommentElement(theElement, theTable);

		getXMLModelSerializer().getXMLAttributeSerializer().deserialize(aModel, theTable, theElement);
		getXMLModelSerializer().getXMLIndexSerializer().deserialize(theTable, theElement);

		aModel.getTables().add(theTable);
	}
}
 
Example #6
Source File: SOFMarkerSegment.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
void updateFromNativeNode(Node node, boolean fromScratch)
    throws IIOInvalidTreeException {
    NamedNodeMap attrs = node.getAttributes();
    int value = getAttributeValue(node, attrs, "process", 0, 2, false);
    tag = (value != -1) ? value+JPEG.SOF0 : tag;
    // If samplePrecision is present, it must be 8.
    // This just checks.  We don't bother to assign the value.
    value = getAttributeValue(node, attrs, "samplePrecision", 8, 8, false);
    value = getAttributeValue(node, attrs, "numLines", 0, 65535, false);
    numLines = (value != -1) ? value : numLines;
    value = getAttributeValue(node, attrs, "samplesPerLine", 0, 65535, false);
    samplesPerLine = (value != -1) ? value : samplesPerLine;
    int numComponents = getAttributeValue(node, attrs, "numFrameComponents",
                                          1, 4, false);
    NodeList children = node.getChildNodes();
    if (children.getLength() != numComponents) {
        throw new IIOInvalidTreeException
            ("numFrameComponents must match number of children", node);
    }
    componentSpecs = new ComponentSpec [numComponents];
    for (int i = 0; i < numComponents; i++) {
        componentSpecs[i] = new ComponentSpec(children.item(i));
    }
}
 
Example #7
Source File: XmlHandler.java    From hop with Apache License 2.0 6 votes vote down vote up
/**
 * Find the value entry in a node
 *
 * @param n The node
 * @return The value entry as a string
 */
public static String getNodeValue( Node n ) {
  if ( n == null ) {
    return null;
  }

  // Find the child-nodes of this Node n:
  NodeList children = n.getChildNodes();
  for ( int i = 0; i < children.getLength(); i++ ) {
    // Try all children
    Node childnode = children.item( i );
    String retval = childnode.getNodeValue();
    if ( retval != null ) { // We found the right value
      return retval;
    }
  }
  return null;
}
 
Example #8
Source File: JPEGMetadata.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
private void mergeStandardTextNode(Node node)
    throws IIOInvalidTreeException {
    // Convert to comments.  For the moment ignore the encoding issue.
    // Ignore keywords, language, and encoding (for the moment).
    // If compression tag is present, use only entries with "none".
    NodeList children = node.getChildNodes();
    for (int i = 0; i < children.getLength(); i++) {
        Node child = children.item(i);
        NamedNodeMap attrs = child.getAttributes();
        Node comp = attrs.getNamedItem("compression");
        boolean copyIt = true;
        if (comp != null) {
            String compString = comp.getNodeValue();
            if (!compString.equals("none")) {
                copyIt = false;
            }
        }
        if (copyIt) {
            String value = attrs.getNamedItem("value").getNodeValue();
            COMMarkerSegment com = new COMMarkerSegment(value);
            insertCOMMarkerSegment(com);
        }
    }
}
 
Example #9
Source File: ExsltSets.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * The set:distinct function returns a subset of the nodes contained in the node-set NS passed
 * as the first argument. Specifically, it selects a node N if there is no node in NS that has
 * the same string value as N, and that precedes N in document order.
 *
 * @param nl NodeList for the node-set.
 * @return a NodeList with nodes from nl containing distinct string values.
 * In other words, if more than one node in nl contains the same string value,
 * only include the first such node found.
 *
 * @see <a href="http://www.exslt.org/">EXSLT</a>
 */
public static NodeList distinct(NodeList nl)
{
  NodeSet dist = new NodeSet();
  dist.setShouldCacheNodes(true);

  Map<String, Node> stringTable = new HashMap<>();

  for (int i = 0; i < nl.getLength(); i++)
  {
    Node currNode = nl.item(i);
    String key = toString(currNode);

    if (key == null)
      dist.addElement(currNode);
    else if (!stringTable.containsKey(key))
    {
      stringTable.put(key, currNode);
      dist.addElement(currNode);
    }
  }

  return dist;
}
 
Example #10
Source File: XmlHandler.java    From hop with Apache License 2.0 6 votes vote down vote up
/**
 * Count nodes with a certain tag
 *
 * @param n   The node to look in
 * @param tag The tags to count
 * @return The number of nodes found with a certain tag
 */
public static int countNodes( Node n, String tag ) {
  NodeList children;
  Node childnode;

  int count = 0;

  if ( n == null ) {
    return 0;
  }

  children = n.getChildNodes();
  for ( int i = 0; i < children.getLength(); i++ ) {
    childnode = children.item( i );
    if ( childnode.getNodeName().equalsIgnoreCase( tag ) ) {
      // <file>
      count++;
    }
  }
  return count;
}
 
Example #11
Source File: AnyTypeBeanInfo.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public void serializeBody(Object element, XMLSerializer target) throws SAXException, IOException, XMLStreamException {
    NodeList childNodes = ((Element)element).getChildNodes();
    int len = childNodes.getLength();
    for( int i=0; i<len; i++ ) {
        Node child = childNodes.item(i);
        switch(child.getNodeType()) {
        case Node.CDATA_SECTION_NODE:
        case Node.TEXT_NODE:
            target.text(child.getNodeValue(),null);
            break;
        case Node.ELEMENT_NODE:
            target.writeDom((Element)child,domHandler,null,null);
            break;
        }
    }
}
 
Example #12
Source File: PluginPackageXmlParser.java    From wecube-platform with Apache License 2.0 6 votes vote down vote up
private Set<PluginPackageDependency> parsePackageDependencies(NodeList packageDependencyNodes,
        PluginPackage pluginPackage) throws XPathExpressionException {
    Set<PluginPackageDependency> pluginPackageDependencies = new LinkedHashSet<>();
    for (int i = 0; i < packageDependencyNodes.getLength(); i++) {
        Node pluginPackageDependencyNode = packageDependencyNodes.item(i);

        PluginPackageDependency pluginPackageDependency = new PluginPackageDependency();
        pluginPackageDependency.setPluginPackage(pluginPackage);

        pluginPackageDependency.setDependencyPackageName(
                getNonNullStringAttribute(pluginPackageDependencyNode, "./@name", "Package dependency name"));
        pluginPackageDependency.setDependencyPackageVersion(
                getNonNullStringAttribute(pluginPackageDependencyNode, "./@version", "Package dependency version"));

        pluginPackageDependency.setPluginPackage(pluginPackage);

        pluginPackageDependencies.add(pluginPackageDependency);
    }
    return pluginPackageDependencies;
}
 
Example #13
Source File: SOFMarkerSegment.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
void updateFromNativeNode(Node node, boolean fromScratch)
    throws IIOInvalidTreeException {
    NamedNodeMap attrs = node.getAttributes();
    int value = getAttributeValue(node, attrs, "process", 0, 2, false);
    tag = (value != -1) ? value+JPEG.SOF0 : tag;
    // If samplePrecision is present, it must be 8.
    // This just checks.  We don't bother to assign the value.
    value = getAttributeValue(node, attrs, "samplePrecision", 8, 8, false);
    value = getAttributeValue(node, attrs, "numLines", 0, 65535, false);
    numLines = (value != -1) ? value : numLines;
    value = getAttributeValue(node, attrs, "samplesPerLine", 0, 65535, false);
    samplesPerLine = (value != -1) ? value : samplesPerLine;
    int numComponents = getAttributeValue(node, attrs, "numFrameComponents",
                                          1, 4, false);
    NodeList children = node.getChildNodes();
    if (children.getLength() != numComponents) {
        throw new IIOInvalidTreeException
            ("numFrameComponents must match number of children", node);
    }
    componentSpecs = new ComponentSpec [numComponents];
    for (int i = 0; i < numComponents; i++) {
        componentSpecs[i] = new ComponentSpec(children.item(i));
    }
}
 
Example #14
Source File: MyBatisGeneratorConfigurationParser.java    From mapper-generator-javafx with Apache License 2.0 6 votes vote down vote up
public Configuration parseConfiguration(Element rootNode)
        throws XMLParserException {

    Configuration configuration = new Configuration();

    NodeList nodeList = rootNode.getChildNodes();
    for (int i = 0; i < nodeList.getLength(); i++) {
        Node childNode = nodeList.item(i);

        if (childNode.getNodeType() != Node.ELEMENT_NODE) {
            continue;
        }

        if ("properties".equals(childNode.getNodeName())) {
            parseProperties(childNode);
        } else if ("classPathEntry".equals(childNode.getNodeName())) {
            parseClassPathEntry(configuration, childNode);
        } else if ("context".equals(childNode.getNodeName())) {
            parseContext(configuration, childNode);
        }
    }

    return configuration;
}
 
Example #15
Source File: XMLUtils.java    From mzmine3 with GNU General Public License v2.0 6 votes vote down vote up
public static Range<Integer> parseIntegerRange(Element xmlElement, String tagName) {
  NodeList items = xmlElement.getElementsByTagName(tagName);
  if (items.getLength() == 0)
    return null;
  Element tag = (Element) items.item(0);
  items = tag.getElementsByTagName("min");
  if (items.getLength() == 0)
    return null;
  Element min = (Element) items.item(0);
  items = tag.getElementsByTagName("max");
  if (items.getLength() == 0)
    return null;
  Element max = (Element) items.item(0);

  String minText = min.getTextContent();
  String maxText = max.getTextContent();
  Range<Integer> r = Range.closed(Integer.valueOf(minText), Integer.valueOf(maxText));
  return r;
}
 
Example #16
Source File: XmlHandler.java    From hop with Apache License 2.0 6 votes vote down vote up
/**
 * Get the value of a tag in a node
 *
 * @param n   The node to look in
 * @param tag The tag to look for
 * @return The value of the tag or null if nothing was found.
 */
public static String getTagValue( Node n, String tag ) {
  NodeList children;
  Node childnode;

  if ( n == null ) {
    return null;
  }

  children = n.getChildNodes();
  for ( int i = 0; i < children.getLength(); i++ ) {
    childnode = children.item( i );
    if ( childnode.getNodeName().equalsIgnoreCase( tag ) ) {
      if ( childnode.getFirstChild() != null ) {
        return childnode.getFirstChild().getNodeValue();
      }
    }
  }
  return null;
}
 
Example #17
Source File: SOFMarkerSegment.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
void updateFromNativeNode(Node node, boolean fromScratch)
    throws IIOInvalidTreeException {
    NamedNodeMap attrs = node.getAttributes();
    int value = getAttributeValue(node, attrs, "process", 0, 2, false);
    tag = (value != -1) ? value+JPEG.SOF0 : tag;
    // If samplePrecision is present, it must be 8.
    // This just checks.  We don't bother to assign the value.
    value = getAttributeValue(node, attrs, "samplePrecision", 8, 8, false);
    value = getAttributeValue(node, attrs, "numLines", 0, 65535, false);
    numLines = (value != -1) ? value : numLines;
    value = getAttributeValue(node, attrs, "samplesPerLine", 0, 65535, false);
    samplesPerLine = (value != -1) ? value : samplesPerLine;
    int numComponents = getAttributeValue(node, attrs, "numFrameComponents",
                                          1, 4, false);
    NodeList children = node.getChildNodes();
    if (children.getLength() != numComponents) {
        throw new IIOInvalidTreeException
            ("numFrameComponents must match number of children", node);
    }
    componentSpecs = new ComponentSpec [numComponents];
    for (int i = 0; i < numComponents; i++) {
        componentSpecs[i] = new ComponentSpec(children.item(i));
    }
}
 
Example #18
Source File: XmlHelper.java    From android-uiconductor with Apache License 2.0 6 votes vote down vote up
private static Node getNodeByXpath(String xml, String xPathString) throws Exception {
  DocumentBuilder builder;
  DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
  Document doc = null;

  try {
    builder = factory.newDocumentBuilder();
    doc = builder.parse(new InputSource(new StringReader(xml)));
  } catch (Exception e) {
    logger.warning("Failed to parse xml." + e.getMessage());
  }
  XPath xpathCompiler = XPathFactory.newInstance().newXPath();

  NodeList nodes =
      (NodeList) xpathCompiler.compile(xPathString).evaluate(doc, XPathConstants.NODESET);
  if (nodes.getLength() == 0) {
    return null;
  }
  return nodes.item(0);
}
 
Example #19
Source File: XmlFileMergerJaxp.java    From mapper-generator-javafx with Apache License 2.0 6 votes vote down vote up
private static boolean isNewFormatNode(Node node) {
    // check for new node format - if the first non-whitespace node
    // is an XML comment, and the comment includes
    // one of the old element tags,
    // then it is a generated node
    NodeList children = node.getChildNodes();
    int length = children.getLength();
    for (int i = 0; i < length; i++) {
        Node childNode = children.item(i);
        if (childNode != null && childNode.getNodeType() == Node.COMMENT_NODE) {
            String commentData = ((Comment) childNode).getData();
            return MergeConstants.comentContainsTag(commentData);
        }
    }
    
    return false;
}
 
Example #20
Source File: ExsltBase.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Return the string value of a Node
 *
 * @param n The Node.
 * @return The string value of the Node
 */
protected static String toString(Node n)
{
  if (n instanceof DTMNodeProxy)
       return ((DTMNodeProxy)n).getStringValue();
  else
  {
    String value = n.getNodeValue();
    if (value == null)
    {
      NodeList nodelist = n.getChildNodes();
      StringBuffer buf = new StringBuffer();
      for (int i = 0; i < nodelist.getLength(); i++)
      {
        Node childNode = nodelist.item(i);
        buf.append(toString(childNode));
      }
      return buf.toString();
    }
    else
      return value;
  }
}
 
Example #21
Source File: FileTypeBox.java    From healthcare-dicom-dicomweb-adapter with Apache License 2.0 6 votes vote down vote up
/** Constructs a <code>FileTypeBox</code> from
 *  <code>org.w3c.dom.Node</code>.
 */
public FileTypeBox(Node node) throws IIOInvalidTreeException {
    super(node);
    NodeList children = node.getChildNodes();

    for (int i = 0; i < children.getLength(); i++) {
        Node child = children.item(i);
        String name = child.getNodeName();

        if ("Brand".equals(name)) {
            brand = Box.getIntElementValue(child);
        }

        if ("MinorVersion".equals(name)) {
            minorVersion = Box.getIntElementValue(child);
        }

        if ("CompatibilityList".equals(name)) {
            compatibility = Box.getIntArrayElementValue(child);
        }
    }
}
 
Example #22
Source File: XMLSchemaInternalizationLogic.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a new XML Schema element of the given local name
 * and insert it as the first child of the given parent node.
 *
 * @return
 *      Newly create element.
 */
private Element insertXMLSchemaElement( Element parent, String localName ) {
    // use the same prefix as the parent node to avoid modifying
    // the namespace binding.
    String qname = parent.getTagName();
    int idx = qname.indexOf(':');
    if(idx==-1)     qname = localName;
    else            qname = qname.substring(0,idx+1)+localName;

    Element child = parent.getOwnerDocument().createElementNS( WellKnownNamespace.XML_SCHEMA, qname );

    NodeList children = parent.getChildNodes();

    if( children.getLength()==0 )
        parent.appendChild(child);
    else
        parent.insertBefore( child, children.item(0) );

    return child;
}
 
Example #23
Source File: XmlHandler.java    From hop with Apache License 2.0 6 votes vote down vote up
/**
 * Get the value of a tag in a node
 *
 * @param n   The node to look in
 * @param tag The tag to look for
 * @return The value of the tag or null if nothing was found.
 */
public static String getTagValueWithAttribute( Node n, String tag, String attribute ) {
  NodeList children;
  Node childnode;

  if ( n == null ) {
    return null;
  }

  children = n.getChildNodes();
  for ( int i = 0; i < children.getLength(); i++ ) {
    childnode = children.item( i );
    if ( childnode.getNodeName().equalsIgnoreCase( tag )
      && childnode.getAttributes().getNamedItem( attribute ) != null ) {
      if ( childnode.getFirstChild() != null ) {
        return childnode.getFirstChild().getNodeValue();
      }
    }
  }
  return null;
}
 
Example #24
Source File: XmlSignature.java    From cstc with GNU General Public License v3.0 6 votes vote down vote up
protected void validateIdAttributes(Document doc) throws Exception {
  String idAttribute = new String(idIdentifier.getText());
  if( idAttribute == null || idAttribute.isEmpty() ) {
    return;
  }
  XPathFactory xPathfactory = XPathFactory.newInstance();
  XPath xpath = xPathfactory.newXPath();
  XPathExpression expr = xpath.compile("descendant-or-self::*/@" + idAttribute);
  NodeList nodeList = (NodeList) expr.evaluate(doc, XPathConstants.NODESET);
  if(nodeList != null && nodeList.getLength() > 0) {
    for(int j = 0; j < nodeList.getLength(); j++) {
        Attr attr = (Attr)nodeList.item(j);
        ((Element)attr.getOwnerElement()).setIdAttributeNode(attr,true);
    }
  }
}
 
Example #25
Source File: XmlHandler.java    From hop with Apache License 2.0 6 votes vote down vote up
/**
 * Get nodes with a certain tag one level down
 *
 * @param n   The node to look in
 * @param tag The tags to count
 * @return The list of nodes found with the specified tag
 */
public static List<Node> getNodes( Node n, String tag ) {
  NodeList children;
  Node childnode;

  List<Node> nodes = new ArrayList<Node>();

  if ( n == null ) {
    return nodes;
  }

  children = n.getChildNodes();
  for ( int i = 0; i < children.getLength(); i++ ) {
    childnode = children.item( i );
    if ( childnode.getNodeName().equalsIgnoreCase( tag ) ) {
      // <file>
      nodes.add( childnode );
    }
  }
  return nodes;
}
 
Example #26
Source File: BaseDefinitionReader.java    From arcusplatform with Apache License 2.0 6 votes vote down vote up
protected T buildModel(Element root) {
   B builder = builder();
   builder
      .withName(root.getAttribute("name"))
      .withNamespace(root.getAttribute("namespace"))
      .withVersion(root.getAttribute("version"));
   
   NodeList nodes = root.getElementsByTagNameNS(schemaURI, "description");
   if (nodes.getLength() > 0)
   {
      Element description = (Element)nodes.item(0);
      builder.withDescription(readDescription(description));
   }
   else {
      logger.warn("No description was given for the capability {}", root.getAttribute("name"));
   }

   populateDefinitionSpecificData(builder, root);

   builder.withMethods(buildMethods(root.getElementsByTagNameNS(schemaURI, "method")));
   builder.withEvents(buildEvents(root.getElementsByTagNameNS(schemaURI, "event")));
   return builder.build();
}
 
Example #27
Source File: CommonAbstractXMLSerializer.java    From MogwaiERDesignerNG with GNU General Public License v3.0 5 votes vote down vote up
protected void deserializeCommentElement(Element aElement, ModelItem aItem) {
	NodeList theChildren = aElement.getChildNodes();
	for (int i = 0; i < theChildren.getLength(); i++) {
		Node theChild = theChildren.item(i);
		if (COMMENT.equals(theChild.getNodeName())) {
			Element theElement = (Element) theChild;
			if (theElement.getChildNodes().getLength() > 0) {
				aItem.setComment(theElement.getChildNodes().item(0).getNodeValue());
			}
		}
	}
}
 
Example #28
Source File: DBUtils.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
private static List<Node> getNodesAsList(Element element) {
	List<Node> nodes = new ArrayList<Node>();
	NodeList nodeList = element.getChildNodes();
	int count = nodeList.getLength();
	for (int i = 0; i < count; i++) {
		nodes.add(nodeList.item(i));
	}
	return nodes;
}
 
Example #29
Source File: UnImplNode.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
/**
 * Unimplemented. See org.w3c.dom.Node
 *
 * @return null
 */
public NodeList getChildNodes()
{

  error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED);  //"getChildNodes not supported!");

  return null;
}
 
Example #30
Source File: XMLUtils.java    From JavaPackager with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Removes whitespaces from nodes
 * @param node Root node
 */
public static void trimWhitespace(Node node) {
    NodeList children = node.getChildNodes();
    for(int i = 0; i < children.getLength(); ++i) {
        Node child = children.item(i);
        if(child.getNodeType() == Node.TEXT_NODE) {
            child.setTextContent(child.getTextContent().trim());
        }
        trimWhitespace(child);
    }
}