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


Java Element.getElementsByTagName方法代码示例

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


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

示例1: loadTableRules

import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
 * tableRule tag:
 * <tableRule name="sharding-by-month">
 * <rule>
 * <columns>create_date</columns>
 * <algorithm>partbymonth</algorithm>
 * </rule>
 * </tableRule>
 *
 * @param root
 * @throws SQLSyntaxErrorException
 */
private void loadTableRules(Element root) throws SQLSyntaxErrorException {
    NodeList list = root.getElementsByTagName("tableRule");
    for (int i = 0, n = list.getLength(); i < n; ++i) {
        Node node = list.item(i);
        if (node instanceof Element) {
            Element e = (Element) node;
            String name = e.getAttribute("name");
            if (StringUtil.isEmpty(name)) {
                throw new ConfigException("name is null or empty");
            }
            if (tableRules.containsKey(name)) {
                throw new ConfigException("table rule " + name + " duplicated!");
            }
            NodeList ruleNodes = e.getElementsByTagName("rule");
            int length = ruleNodes.getLength();
            if (length > 1) {
                throw new ConfigException("only one rule can defined :" + name);
            }
            //rule has only one element now. Maybe it will not contains one rule in feature
            //RuleConfig:rule->function
            RuleConfig rule = loadRule((Element) ruleNodes.item(0));
            tableRules.put(name, new TableRuleConfig(name, rule));
        }
    }
}
 
开发者ID:actiontech,项目名称:dble,代码行数:38,代码来源:XMLRuleLoader.java

示例2: extract

import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
 * 提取出xml数据包中的加密消息
 * @param xmltext 待提取的xml字符串
 * @return 提取出的加密消息字符串
 * @throws AesException 
 */
public static Object[] extract(String xmltext) throws AesException     {
	Object[] result = new Object[3];
	try {
		DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
		DocumentBuilder db = dbf.newDocumentBuilder();
		StringReader sr = new StringReader(xmltext);
		InputSource is = new InputSource(sr);
		Document document = db.parse(is);

		Element root = document.getDocumentElement();
		NodeList nodelist1 = root.getElementsByTagName("Encrypt");
		NodeList nodelist2 = root.getElementsByTagName("ToUserName");
		result[0] = 0;
		result[1] = nodelist1.item(0).getTextContent();
		result[2] = nodelist2.item(0).getTextContent();
		return result;
	} catch (Exception e) {
		e.printStackTrace();
		throw new AesException(AesException.ParseXmlError);
	}
}
 
开发者ID:jweixin,项目名称:jwx,代码行数:28,代码来源:XMLParse.java

示例3: parseRegionElement

import org.w3c.dom.Element; //导入方法依赖的package包/类
private static Region parseRegionElement(
        final Element regionElement,
        final boolean endpointVerification) {

    String name = getChildElementValue(REGION_ID_TAG, regionElement);
    String domain = getChildElementValue(DOMAIN_TAG, regionElement);

    InMemoryRegionImpl regionImpl = new InMemoryRegionImpl(name, domain);

    NodeList endpointNodes =
        regionElement.getElementsByTagName(ENDPOINT_TAG);

    for (int i = 0; i < endpointNodes.getLength(); i++) {
        addRegionEndpoint(regionImpl,
                          (Element) endpointNodes.item(i),
                          endpointVerification);
    }

    return new Region(regionImpl);
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:21,代码来源:RegionMetadataParser.java

示例4: LoadFromXML

import org.w3c.dom.Element; //导入方法依赖的package包/类
@Override
public boolean LoadFromXML(Element me, boolean colando) {
    boolean res = super.LoadFromXML(me, colando);
    if (!res) {
        return res;
    }
    NodeList ptLst = me.getElementsByTagName(FluxTexto.class.getSimpleName());
    if (ptLst.getLength() > 0) {
        Element ecard = (Element) ptLst.item(0);
        PrepareTexto();
        PreTextoApenso txt = getTexto();
        if (txt != null) {
            txt.LoadFromXML(ecard, colando);
        }
    }
    return true;
}
 
开发者ID:chcandido,项目名称:brModelo,代码行数:18,代码来源:FluxSeta.java

示例5: preconfigure

import org.w3c.dom.Element; //导入方法依赖的package包/类
@Override
public void preconfigure(Element element) throws Exception {
	super.preconfigure(element);
	
	String version = element.getAttribute("version");
	if (VersionUtils.compare(version, "7.5.0") < 0) {
		NodeList properties = element.getElementsByTagName("property");
		
		Element propName = (Element) XMLUtils.findNodeByAttributeValue(properties, "name", "isEnable");
		if (propName != null) {
			propName.setAttribute("name", "isEnabled");
			hasChanged = true;
		}

		Engine.logBeans.warn("[Listener] The object \"" + getName() + "\" has been updated to version 7.5.0 (property \"isEnable\" changed to \"isEnabled\")");
	}
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:18,代码来源:Listener.java

示例6: deploymentAndLang

import org.w3c.dom.Element; //导入方法依赖的package包/类
private void deploymentAndLang(Element docElement, AppConfigurations configs){
    NodeList deploymentModeNodeList = docElement.getElementsByTagName("deployment-mode");

    if(deploymentModeNodeList.getLength()>0){
        String deploymentModevalue = deploymentModeNodeList.item(0).getTextContent();
        if(deploymentModevalue.equals("PRODUCTION"))
            configs.setDeploymentMode(AppConfigurations.DeploymentMode.PRODUCTION);
    }

    NodeList defaultLangNode = docElement.getElementsByTagName("default-lang");
    if(defaultLangNode.getLength()>0){
        org.w3c.dom.Element defaultLangElement = (org.w3c.dom.Element) defaultLangNode.item(0);
        configs.setDefaultLanguage(defaultLangElement.getTextContent());
    }

}
 
开发者ID:Emerjoin,项目名称:Hi-Framework,代码行数:17,代码来源:WebConfig.java

示例7: childSpi

import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
 * Retrieves this node's child with the given name from the backing store. If
 * such a child doesn't exist, one will be created.
 * @param name the name of the desired child
 * @return the desired node, which will have the 'newNode' flag set if it didn't
 * exist before this method
 */
protected AbstractPreferences childSpi(String name) {
	Element node = myXMLNode();
	
	if (node != null) {
		NodeList children = node.getElementsByTagName("node");
		
		for (int i=0 ; i<children.getLength() ; i++) {
			Element child = (Element)children.item(i);
			String childName = child.getAttribute("name");
			
			if (childName.equals(name)) 
				return createPreferencesFromElement(child,childName);
		}
		
		// the child doesn't exist, so one will be created
		AbstractPreferences prefs = new AIXMLPreferences(this,name);
		Element newNode = AIPreferencesController.getInstance().getXMLDocument().createElement("node");
		Element map = AIPreferencesController.getInstance().getXMLDocument().createElement("map");
		
		newNode.appendChild(map);
		newNode.setAttribute("name",name);
		node.appendChild(newNode);

		return prefs;
	}
	return null;
}
 
开发者ID:guilhebl,项目名称:routerapp,代码行数:35,代码来源:AIXMLPreferences.java

示例8: SentenceStruct

import org.w3c.dom.Element; //导入方法依赖的package包/类
public SentenceStruct(Element S) {
    NodeList Ws = S.getElementsByTagName("W");
    for (int j = 0; j < Ws.getLength(); j++) {
        WordStruct word = new WordStruct();
        word.word = Ws.item(j).getFirstChild().getNodeValue();
        add(word);
    }
}
 
开发者ID:radsimu,项目名称:UaicNlpToolkit,代码行数:9,代码来源:SentenceStruct.java

示例9: parseGroup

import org.w3c.dom.Element; //导入方法依赖的package包/类
private Group parseGroup(final Element element) {
    final Group.Builder builder = new Group.Builder()
            .identifier(element.getAttribute(IDENTIFIER_ATTR))
            .name(element.getAttribute(NAME_ATTR));

    NodeList groupUsers = element.getElementsByTagName(GROUP_USER_ELEMENT);
    for (int i=0; i < groupUsers.getLength(); i++) {
        Element groupUserNode = (Element) groupUsers.item(i);
        builder.addUser(groupUserNode.getAttribute(IDENTIFIER_ATTR));
    }

    return builder.build();
}
 
开发者ID:apache,项目名称:nifi-registry,代码行数:14,代码来源:AbstractPolicyBasedAuthorizer.java

示例10: SetFormProperties

import org.w3c.dom.Element; //导入方法依赖的package包/类
private void SetFormProperties(Element eOutput, Element eData)
{
	NodeList lstForms = eOutput.getElementsByTagName("form") ;
	int nb = lstForms.getLength() ;
	for (int i=0; i<nb; i++)
	{
		Element eForm = (Element)lstForms.item(i) ;
		String name = eForm.getAttribute("name") ;
		String dataname = eData.getAttribute("name") ;
		if (m_AppSession.isZoom())
			eForm.setAttribute("zoom", "true") ;
		else
			eForm.setAttribute("zoom", "false") ;
		if (m_AppSession.isBold())
			eForm.setAttribute("bold", "true") ;
		else
			eForm.setAttribute("bold", "false") ;
		//eForm.setAttribute("cmpSession", m_AppSession.getCmp()) ;
		if (name.equals(dataname))
		{
			String lang = eData.getAttribute("lang") ;
			eOutput.setAttribute("lang", lang) ;
		}
		if (m_CursorField != null)
		{
			String cur = m_CursorField.getAttribute("name");
			eForm.setAttribute("cursor", cur) ;
		}
		String cs = eData.getAttribute("printScreen") ;
		if  (cs != null && cs.equals("show"))
		{
			eForm.setAttribute("printScreen", "show") ;
		}
		
	}
}
 
开发者ID:costea7,项目名称:ChronoBike,代码行数:37,代码来源:XMLMerger.java

示例11: getElements

import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
 * Gets the descendant elements list from the parent element.
 *
 * @param parent the parent element in the element tree
 * @param tagName the specified tag name
 * @return the NOT NULL descendant elements list
 */
public static List<Element> getElements(Element parent, String tagName) {
    NodeList nodes = parent.getElementsByTagName(tagName);
    List<Element> elements = new ArrayList<Element>();

    for (int i = 0; i < nodes.getLength(); i++) {
        Node node = nodes.item(i);
        if (node instanceof Element) {
            elements.add((Element) node);
        }
    }

    return elements;
}
 
开发者ID:wendal,项目名称:alipay-sdk,代码行数:21,代码来源:XmlUtils.java

示例12: getWsdlBackupDir

import org.w3c.dom.Element; //导入方法依赖的package包/类
protected String getWsdlBackupDir(Element element) throws Exception {
  	Element rootElement = element.getOwnerDocument().getDocumentElement();
  	Element projectNode = (Element) XMLUtils.findChildNode(rootElement, Node.ELEMENT_NODE);
  	NodeList properties = projectNode.getElementsByTagName("property");
Element pName = (Element) XMLUtils.findNodeByAttributeValue(properties, "name", "name");
String projectName = (String) XMLUtils.readObjectFromXml((Element) XMLUtils.findChildNode(pName, Node.ELEMENT_NODE));
  	return Engine.PROJECTS_PATH + "/"+ projectName + "/backup-wsdl";
  }
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:9,代码来源:RequestableObject.java

示例13: getRobotCoordinateZ

import org.w3c.dom.Element; //导入方法依赖的package包/类
private String getRobotCoordinateZ(Element info, String tagcoordinate, String tagdimension){
      String valuez = "";        
NodeList coordinateNmElmntLst = info.getElementsByTagName(tagcoordinate);
Node coordinateNode = coordinateNmElmntLst.item(0);
if (coordinateNode.getNodeType() == Node.ELEMENT_NODE){
 Element coorInfo = (Element) coordinateNode;			  			  
 //Obtain information about z coordinate for the current robot 
 NodeList zNmElmntLst = coorInfo.getElementsByTagName(tagdimension);
 Element zNmElmnt = (Element) zNmElmntLst.item(0);
 NodeList zNm = zNmElmnt.getChildNodes();					  
 valuez = ((Node)zNm.item(0)).getNodeValue();				  
}
return valuez;
}
 
开发者ID:Yarichi,项目名称:Proyecto-DASI,代码行数:15,代码来源:ReadXMLTestRobotsConstructorEscenarios.java

示例14: getVictimCoordinateY

import org.w3c.dom.Element; //导入方法依赖的package包/类
private String getVictimCoordinateY(Element info, String tagcoordinate, String tagdimension){
      String valuey = "";        
NodeList coordinateNmElmntLst = info.getElementsByTagName(tagcoordinate);
Node coordinateNode = coordinateNmElmntLst.item(0);
if (coordinateNode.getNodeType() == Node.ELEMENT_NODE){
 Element coorInfo = (Element) coordinateNode;			  			  
 //Obtain information about y coordinate for the current victim 
 NodeList yNmElmntLst = coorInfo.getElementsByTagName(tagdimension);
 Element yNmElmnt = (Element) yNmElmntLst.item(0);
 NodeList yNm = yNmElmnt.getChildNodes();					  
 valuey = ((Node)yNm.item(0)).getNodeValue();					  
}
return valuey;
}
 
开发者ID:Yarichi,项目名称:Proyecto-DASI,代码行数:15,代码来源:ReadXMLTestSequence.java

示例15: removeColumnsFromDocument

import org.w3c.dom.Element; //导入方法依赖的package包/类
private void removeColumnsFromDocument(){
    Element dataset = getDatasetElement();
    NodeList fields = dataset.getElementsByTagName("field");
    List<String> columnNames = new ArrayList<>();
    for (int i = 0; i < fields.getLength(); i++) {
        Element column = (Element) fields.item(i);
        columnNames.add(column.getAttribute("name"));
    }
    columnNames.forEach(this::removeColumnFromDocument);
}
 
开发者ID:NVIvanov,项目名称:jrbuilder,代码行数:11,代码来源:DefaultReport.java


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