当前位置: 首页>>代码示例>>Java>>正文


Java Node.hasChildNodes方法代码示例

本文整理汇总了Java中org.w3c.dom.Node.hasChildNodes方法的典型用法代码示例。如果您正苦于以下问题:Java Node.hasChildNodes方法的具体用法?Java Node.hasChildNodes怎么用?Java Node.hasChildNodes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.w3c.dom.Node的用法示例。


在下文中一共展示了Node.hasChildNodes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: GetNodeText

import org.w3c.dom.Node; //导入方法依赖的package包/类
static public String GetNodeText(Node parent) {
	String s;
	StringBuffer value;
	NodeList nodes;
	Node node;
	int n;

	value=new StringBuffer(""); 
	if (parent.hasChildNodes()) {
		nodes=parent.getChildNodes();
		for(n=0;n<nodes.getLength();n++) { 
			node=nodes.item(n);
			if (node.getNodeType()==Node.TEXT_NODE)
				value.append(node.getNodeValue());
			if (node.hasChildNodes())
				value.append(GetNodeText(node));
		}
	} else {
		s=parent.getNodeValue();
		if (s!=null) return s; else return "";
	}
	return value.toString();
}
 
开发者ID:costea7,项目名称:ChronoBike,代码行数:24,代码来源:XmlHelper.java

示例2: parseDocument

import org.w3c.dom.Node; //导入方法依赖的package包/类
private static Flag parseDocument(Node node) throws IOException {
	String type = node.getNodeName();
	if (type.equalsIgnoreCase("#document")) {
		for (Node child : getChildren(node)) {
			String ctype = child.getNodeName();
			if (ctype.equalsIgnoreCase("flag")) {
				if (child.hasAttributes() || child.hasChildNodes()) {
					return parseFlag(child);
				}
			} else {
				throw new IOException("Unknown element: " + ctype);
			}
		}
		throw new IOException("Empty document.");
	} else {
		throw new IOException("Unknown element: " + type);
	}
}
 
开发者ID:kreativekorp,项目名称:vexillo,代码行数:19,代码来源:FlagParser.java

示例3: loadIniSettings

import org.w3c.dom.Node; //导入方法依赖的package包/类
public static  LinkedList<Map<String,String>> loadIniSettings(String filePath){ 
	LinkedList<Map<String,String>> xmlExtrakt = new LinkedList<Map<String,String>>();
	Document doc= getXmlDocument(filePath);	
	Map<String,String> tagsAndContents = new HashMap<String,String>();

	Node lastDir = getElementByTagName(doc,"LASTDIR" );
	if (lastDir!=null &&lastDir.hasChildNodes()){
		String lastDirLocator = lastDir.getFirstChild().getNodeValue();
		if (lastDirLocator!=null && lastDirLocator.trim()!=null){
		tagsAndContents.put("LASTDIR",lastDirLocator);
		xmlExtrakt.add(tagsAndContents);
		}
	}
	
	Node warnLvlNode = getElementByTagName(doc,"WARNINGLEVEL" );
	if (warnLvlNode!=null && warnLvlNode.hasChildNodes()){
		String warnLvl = warnLvlNode.getFirstChild().getNodeValue();
		if (warnLvl!=null && warnLvl.trim()!=null){
		tagsAndContents.put("WARNINGLEVEL",warnLvl);
		xmlExtrakt.add(tagsAndContents);
		}
	}
	
	//System.out.println(xmlExtrakt);
    return xmlExtrakt;
}
 
开发者ID:RaduMarcel,项目名称:EspressoViews,代码行数:27,代码来源:QueryDefinitionParser.java

示例4: storeIniSettings

import org.w3c.dom.Node; //导入方法依赖的package包/类
public static void storeIniSettings( String iniFile, String iniSettingName,String iniSettingValue){
	Document doc= getXmlDocument((new File (iniFile)).getAbsolutePath() );	
	Node lastDir = getElementByTagName(doc,iniSettingName );
	if (lastDir==null ){//neues ini setting tag kreieren
		Element neuesElement = doc.createElement(iniSettingName);
		neuesElement.appendChild(doc.createTextNode(iniSettingValue));
		getElementByTagName(doc,"ROOT" ).appendChild(neuesElement);
	}
	else 
		if (lastDir.hasChildNodes()){//altes ini setting �berschreiben
			lastDir.getFirstChild().setTextContent(iniSettingValue); 
		}
	if (lastDir!= null && !lastDir.hasChildNodes()){//ini setting im leeren tag schreiben 
		lastDir.appendChild(doc.createTextNode(iniSettingValue)); 
	}
	storeXmlDocToFile(iniFile, doc);	
}
 
开发者ID:RaduMarcel,项目名称:EspressoViews,代码行数:18,代码来源:QueryDefinitionParser.java

示例5: importNode

import org.w3c.dom.Node; //导入方法依赖的package包/类
@Override
public org.w3c.dom.Node importNode(Node importedNode, boolean deep)
    throws DOMException {
    Node domNode = getDomNode(importedNode);
    final Node newNode = document.importNode(domNode, deep);

    if (importedNode instanceof javax.xml.soap.Node) {
        Node newSoapNode = createSoapNode(importedNode.getClass(), newNode);
        newNode.setUserData(SAAJ_NODE, newSoapNode, null);
        if (deep && importedNode.hasChildNodes()) {
            NodeList childNodes = importedNode.getChildNodes();
            for (int i = 0; i < childNodes.getLength(); i++) {
                registerChildNodes(childNodes.item(i), deep);
            }
        }
        return newSoapNode;
    }

    registerChildNodes(newNode, deep);
    return findIfPresent(newNode);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:SOAPDocumentImpl.java

示例6: getNormalizedText

import org.w3c.dom.Node; //导入方法依赖的package包/类
public static String getNormalizedText(Node node) {
	String res = "";
	if (node.hasChildNodes()) {
		NodeList nl = node.getChildNodes();
		for (int i = 0; i < nl.getLength(); i++) {
			if (nl.item(i).getNodeType() == Node.TEXT_NODE) {
				res += nl.item(i).getNodeValue();
			} else {
				// ignore <SCRIPT> nodes ...
				if (!nl.item(i).getNodeName().equalsIgnoreCase("script"))
					res += getNormalizedText(nl.item(i));
			}
		}
	}
	return res;
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:17,代码来源:XMLUtils.java

示例7: findChildrenNodes

import org.w3c.dom.Node; //导入方法依赖的package包/类
private List<Node> findChildrenNodes(Node node) {
    List<Node> nodes = new ArrayList<>();
    for (int i = 0; i < node.getChildNodes().getLength(); i++) {
        Node n = node.getChildNodes().item(i);
        nodes.add(n);
        if (n.hasChildNodes()) {
            nodes.addAll(findChildrenNodes(n));
        }
    }
    return nodes;
}
 
开发者ID:Scrumplex,项目名称:FXMLHelper,代码行数:12,代码来源:ControllerGeneratorAction.java

示例8: if

import org.w3c.dom.Node; //导入方法依赖的package包/类
/**
 *
 * @param listVector
 * @param tempNode
 * @param tagname
 * @param isTagNameWildCard
 *
 *
 * Private method to be used for recursive iterations to obtain elements by tag name.
 */
private final void traverseChildren
(
  Vector listVector,
  Node tempNode,
  String tagname,
  boolean isTagNameWildCard) {
  if (tempNode == null)
  {
    return;
  }
  else
  {
    if (tempNode.getNodeType() == DTM.ELEMENT_NODE
          && (isTagNameWildCard || tempNode.getNodeName().equals(tagname)))
    {
      listVector.add(tempNode);
    }
    if(tempNode.hasChildNodes())
    {
      NodeList nodeList = tempNode.getChildNodes();
      for (int i = 0; i < nodeList.getLength(); i++)
      {
        traverseChildren(listVector, nodeList.item(i), tagname,
                         isTagNameWildCard);
      }
    }
  }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:39,代码来源:DTMNodeProxy.java

示例9: showMeTheDoc

import org.w3c.dom.Node; //导入方法依赖的package包/类
public static void showMeTheDoc(Node node, int level ){
	//if (node.getNodeType()==1)
	if (node.hasAttributes()) System.out.println(node.getAttributes());
    System.out.println("Level "+level+DisplayData.multiplyChars(' ',(level-1)*10)+" Der Knoten "+node.getNodeName()
    		//+" mit dem Inhalt "+" Node Text Content: "+node.getTextContent()
    		+" und mit dem Node Type "+node.getNodeType()+" und node value: "+node.getNodeValue()
    		+" hat "+node.getChildNodes().getLength()+" Kinder "
    		);
    	if (node.hasChildNodes()){
			 NodeList children=  node.getChildNodes();
		 for (int t = 0;t<children.getLength();t++){
			showMeTheDoc(children.item(t), level+1);
		 }
	   }
}
 
开发者ID:RaduMarcel,项目名称:EspressoViews,代码行数:16,代码来源:QueryDefinitionParser.java

示例10: getChildNode

import org.w3c.dom.Node; //导入方法依赖的package包/类
private Node getChildNode(Node node, String childName) {
    Node childNode = null;
    if(node.hasChildNodes()) {
        NodeList childNodes = node.getChildNodes();
        int length = childNodes.getLength();
        for(int i = 0; i < length; i++) {
            Node item = childNodes.item(i);
            if(item.getNodeName().equals(childName)) {
                childNode = item;
                break;
            }
        }
    }
    return childNode;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:TIFFImageMetadata.java

示例11: removeAll

import org.w3c.dom.Node; //导入方法依赖的package包/类
public static void removeAll(Node node) {
    NodeList list = node.getChildNodes();
    for (int i = 0; i < list.getLength(); i++) {
        Node n = list.item(i);
        if (n.hasChildNodes()) {
            removeAll(n);
            node.removeChild(n);
        } else {
            node.removeChild(n);
        }
    }
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:13,代码来源:XMLOperation.java

示例12: person

import org.w3c.dom.Node; //导入方法依赖的package包/类
/**
 * evaluate tag contents and swap 1st and 2nd person pronouns
 * implements {@code <person>} tag
 *
 * @param node     current XML parse node
 * @param ps       AIML parse state
 * @return         sentence with pronouns swapped
 */
private static String person(Node node, ParseState ps) {
    String result;
    if (node.hasChildNodes())
      result = evalTagContent(node, ps, null);
    else result = ps.starBindings.inputStars.star(0);   // for <person/>
    result = " "+result+" ";
    result = ps.chatSession.bot.preProcessor.person(result);
    return result.trim();
}
 
开发者ID:Suhas010,项目名称:Artificial-Intelligent-chat-bot-,代码行数:18,代码来源:AIMLProcessor.java

示例13: cloneNodeWithUserData

import org.w3c.dom.Node; //导入方法依赖的package包/类
private static Node cloneNodeWithUserData(Node node, boolean recurse) {
	if (node != null) {
		Object node_output = node.getUserData(Step.NODE_USERDATA_OUTPUT);

		Node clonedNode = node.cloneNode(false);
		clonedNode.setUserData(Step.NODE_USERDATA_OUTPUT, node_output, null);
		
		if (node.getNodeType() == Node.ELEMENT_NODE) {
			// attributes
			NamedNodeMap attributeMap = clonedNode.getAttributes();
			for (int i=0; i< attributeMap.getLength(); i++) {
				Node clonedAttribute = attributeMap.item(i);
				String attr_name = clonedAttribute.getNodeName();
				Object attr_output = ((Element)node).getAttributeNode(attr_name).getUserData(Step.NODE_USERDATA_OUTPUT);
				clonedAttribute.setUserData(Step.NODE_USERDATA_OUTPUT, attr_output, null);
			}
			
			// recurse on element child nodes only
			if (recurse && node.hasChildNodes()) {
				NodeList list = node.getChildNodes();
				for (int i=0; i<list.getLength(); i++) {
					Node clonedChild = cloneNodeWithUserData(list.item(i), recurse);
					if (clonedChild != null) {
						clonedNode.appendChild(clonedChild);
					}
				}
			}
		}
		
		return clonedNode;
	}
	return null;
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:34,代码来源:Sequence.java

示例14: if

import org.w3c.dom.Node; //导入方法依赖的package包/类
/**
 *
 * @param listVector
 * @param tempNode
 * @param namespaceURI
 * @param localname
 * @param isNamespaceURIWildCard
 * @param isLocalNameWildCard
 *
 * Private method to be used for recursive iterations to obtain elements by tag name
 * and namespaceURI.
 */
private final void traverseChildren
(
 Vector listVector,
 Node tempNode,
 String namespaceURI,
 String localname,
 boolean isNamespaceURIWildCard,
 boolean isLocalNameWildCard)
 {
  if (tempNode == null)
  {
    return;
  }
  else
  {
    if (tempNode.getNodeType() == DTM.ELEMENT_NODE
            && (isLocalNameWildCard
                    || tempNode.getLocalName().equals(localname)))
    {
      String nsURI = tempNode.getNamespaceURI();
      if ((namespaceURI == null && nsURI == null)
             || isNamespaceURIWildCard
             || (namespaceURI != null && namespaceURI.equals(nsURI)))
      {
        listVector.add(tempNode);
      }
    }
    if(tempNode.hasChildNodes())
    {
      NodeList nl = tempNode.getChildNodes();
      for(int i = 0; i < nl.getLength(); i++)
      {
        traverseChildren(listVector, nl.item(i), namespaceURI, localname,
                         isNamespaceURIWildCard, isLocalNameWildCard);
      }
    }
  }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:51,代码来源:DTMNodeProxy.java

示例15: getLastChild

import org.w3c.dom.Node; //导入方法依赖的package包/类
/** Internal function.
 *  Return the last child Node, from the input node
 *  after applying filter, whatToshow.
 *  The current node is not consulted or set.
 */
Node getLastChild(Node node) {

    if (node == null) return null;

    if ( !fEntityReferenceExpansion
         && node.getNodeType() == Node.ENTITY_REFERENCE_NODE)
        return null;

    Node newNode = node.getLastChild();
    if (newNode == null)  return null;

    int accept = acceptNode(newNode);

    if (accept == NodeFilter.FILTER_ACCEPT)
        return newNode;
    else
    if (accept == NodeFilter.FILTER_SKIP
        && newNode.hasChildNodes())
    {
        Node lChild = getLastChild(newNode);
        if (lChild == null) {
            return getPreviousSibling(newNode, node);
        }
        return lChild;
    }
    else
    //if (accept == NodeFilter.REJECT_NODE)
    {
        return getPreviousSibling(newNode, node);
    }


}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:39,代码来源:TreeWalkerImpl.java


注:本文中的org.w3c.dom.Node.hasChildNodes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。