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


Java Element.getFirstChild方法代码示例

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


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

示例1: parseParameterArray

import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
 * Parses a parameter array and returns Vector of found subParameters
 * @param parameterNode
 * @return Vector with found subParameters
 */
protected static Vector<Node> parseParameterArray(Element parameterNode) {
	Vector<Node> ret = new Vector<Node>();
	Node child = parameterNode.getFirstChild();

	while (child != null) {
		while (child != null && (child.getNodeType() != Node.ELEMENT_NODE || !child.getNodeName().equals(XML_E_SUBPARAMETER))) {
			child = child.getNextSibling();
		}

		if (child == null) {
			break;
		}
		// Puts found subParameter into destination Vector
		ret.add(child);
		child = child.getNextSibling();
	}

	return ret;
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:25,代码来源:XMLReader.java

示例2: matches

import org.w3c.dom.Element; //导入方法依赖的package包/类
@Override
public boolean matches(Element element) {
    for (Node child = element.getFirstChild(); child != null; child = child.getNextSibling()) {
        short type = child.getNodeType();
        if (type == Node.ELEMENT_NODE) {
            return false;
        } else if (type == Node.TEXT_NODE ||
                   type == Node.CDATA_SECTION_NODE ||
                   type == Node.ENTITY_REFERENCE_NODE) {
            String content = child.getTextContent();
            if (content != null && !content.isEmpty()) {
                return false;
            }
        }
    }
    return true;
}
 
开发者ID:i49,项目名称:cascade,代码行数:18,代码来源:EmptyMatcher.java

示例3: getFirstElementChild

import org.w3c.dom.Element; //导入方法依赖的package包/类
public static Element getFirstElementChild(Element element, String namespace,
        String localname) {
    ParamUtil.requireNonNull("element", element);
    ParamUtil.requireNonBlank("localname", localname);
    Node node = element.getFirstChild();
    if (node == null) {
        return null;
    }

    do {
        if (match(node, namespace, localname)) {
            return (Element) node;
        }
        node = node.getNextSibling();
    }
    while (node != null);
    return null;
}
 
开发者ID:xipki,项目名称:xitk,代码行数:19,代码来源:XmlUtil.java

示例4: unmarshalKeyValue

import org.w3c.dom.Element; //导入方法依赖的package包/类
PublicKey unmarshalKeyValue(Element kvtElem)
    throws MarshalException
{
    if (rsakf == null) {
        try {
            rsakf = KeyFactory.getInstance("RSA");
        } catch (NoSuchAlgorithmException e) {
            throw new RuntimeException
                ("unable to create RSA KeyFactory: " + e.getMessage());
        }
    }
    Element modulusElem = DOMUtils.getFirstChildElement(kvtElem,
                                                        "Modulus");
    modulus = new DOMCryptoBinary(modulusElem.getFirstChild());
    Element exponentElem = DOMUtils.getNextSiblingElement(modulusElem,
                                                          "Exponent");
    exponent = new DOMCryptoBinary(exponentElem.getFirstChild());
    RSAPublicKeySpec spec = new RSAPublicKeySpec(modulus.getBigNum(),
                                                 exponent.getBigNum());
    return generatePublicKey(rsakf, spec);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:22,代码来源:DOMKeyValue.java

示例5: decode

import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
 * Method decode
 *
 * Takes the <CODE>Text</CODE> children of the Element and interprets
 * them as input for the <CODE>Base64.decode()</CODE> function.
 *
 * @param element
 * @return the byte obtained of the decoding the element
 * $todo$ not tested yet
 * @throws Base64DecodingException
 */
public static final byte[] decode(Element element) throws Base64DecodingException {

    Node sibling = element.getFirstChild();
    StringBuffer sb = new StringBuffer();

    while (sibling != null) {
        if (sibling.getNodeType() == Node.TEXT_NODE) {
            Text t = (Text) sibling;

            sb.append(t.getData());
        }
        sibling = sibling.getNextSibling();
    }

    return decode(sb.toString());
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:28,代码来源:Base64.java

示例6: getNodeValue

import org.w3c.dom.Element; //导入方法依赖的package包/类
/** Return the text value of the first child of the named node, or the specified default if the node can't be found.<br>
 * For example, calling getNodeValue(el, "Mode", "whatever") on a list of elements which contains the following XML:
 *  <Mode>survival</Mode>
 * should return "survival".
 * @param elements the list of XML elements to search
 * @param nodeName the name of the parent node to extract the text value from
 * @param defaultValue the default to return if the node is empty / doesn't exist
 * @return the text content of the desired element
 */
static public String getNodeValue(List<Element> elements, String nodeName, String defaultValue)
{
    if (elements != null)
    {
        for (Element el : elements)
        {
            if (el.getNodeName().equals(nodeName))
            {
                if (el.getFirstChild() != null)
                {
                    return el.getFirstChild().getTextContent();
                }
            }
        }
    }
    return defaultValue;
}
 
开发者ID:Yarichi,项目名称:Proyecto-DASI,代码行数:27,代码来源:SchemaHelper.java

示例7: decode

import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
 * Method decode
 *
 * Takes the <CODE>Text</CODE> children of the Element and interprets
 * them as input for the <CODE>Base64.decode()</CODE> function.
 *
 * @param element
 * @return the byte obtained of the decoding the element
 * $todo$ not tested yet
 * @throws Base64DecodingException
 */
public static final byte[] decode(Element element) throws Base64DecodingException {

    Node sibling = element.getFirstChild();
    StringBuilder sb = new StringBuilder();

    while (sibling != null) {
        if (sibling.getNodeType() == Node.TEXT_NODE) {
            Text t = (Text) sibling;

            sb.append(t.getData());
        }
        sibling = sibling.getNextSibling();
    }

    return decode(sb.toString());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:28,代码来源:Base64.java

示例8: countKids

import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
 * Count number of children of a certain type of the given element.
 *
 * @param elem the element whose kids are to be counted
 *
 * @return the number of matching kids.
 */
public static int countKids (Element elem, short nodeType) {
    int nkids = 0;
    for (Node n = elem.getFirstChild (); n != null; n = n.getNextSibling ()) {
        if (n.getNodeType () == nodeType) {
            nkids++;
        }
    }
    return nkids;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:17,代码来源:DOMUtils.java

示例9: walkTree

import org.w3c.dom.Element; //导入方法依赖的package包/类
public static void walkTree(Element start, Consumer<Element> consumer) {
    consumer.accept(start);
    Node child = start.getFirstChild();
    while (child != null) {
        if (child.getNodeType() == Node.ELEMENT_NODE) {
            walkTree((Element)child, consumer);
        }
        child = child.getNextSibling();
    }
}
 
开发者ID:i49,项目名称:cascade,代码行数:11,代码来源:Documents.java

示例10: loopDoorChildren

import org.w3c.dom.Element; //导入方法依赖的package包/类
private void loopDoorChildren(final Context context, final Element element, final Map<Child, Object> childValues)
        throws XmlException {
    Node childElement = element.getFirstChild();
    while (childElement != null) {
        verwerkChildElement(context, childValues, childElement);

        childElement = childElement.getNextSibling();
    }
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:10,代码来源:CompositeObject.java

示例11: testComments002

import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
 * Equivalence class partitioning with state and input values orientation
 * for public void setParameter(String name, Object value) throws
 * DOMException, <br>
 * <b>pre-conditions</b>: the root element has two Comment nodes, <br>
 * <b>name</b>: comments <br>
 * <b>value</b>: false. <br>
 * <b>Expected results</b>: the root element has no children
 */
@Test
public void testComments002() {
    DOMImplementation domImpl = null;
    try {
        domImpl = DocumentBuilderFactory.newInstance().newDocumentBuilder().getDOMImplementation();
    } catch (ParserConfigurationException pce) {
        Assert.fail(pce.toString());
    } catch (FactoryConfigurationError fce) {
        Assert.fail(fce.toString());
    }

    Document doc = domImpl.createDocument("namespaceURI", "ns:root", null);

    Comment comment1 = doc.createComment("comment1");
    Comment comment2 = doc.createComment("comment2");

    DOMConfiguration config = doc.getDomConfig();
    config.setParameter("comments", Boolean.FALSE);

    Element root = doc.getDocumentElement();
    root.appendChild(comment1);
    root.appendChild(comment2);

    doc.normalizeDocument();

    if (root.getFirstChild() != null) {
        Assert.fail("root has a child " + root.getFirstChild() + ", but expected to has none");
    }

    return; // Status.passed("OK");

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

示例12: create

import org.w3c.dom.Element; //导入方法依赖的package包/类
/**
 * Creates a {@link Message} from an {@link Element} that represents
 * the whole SOAP message.
 *
 * @param soapEnvelope
 *      The SOAP envelope element.
 */
public static Message create(Element soapEnvelope) {
    SOAPVersion ver = SOAPVersion.fromNsUri(soapEnvelope.getNamespaceURI());
    // find the headers
    Element header = DOMUtil.getFirstChild(soapEnvelope, ver.nsUri, "Header");
    HeaderList headers = null;
    if(header!=null) {
        for( Node n=header.getFirstChild(); n!=null; n=n.getNextSibling() ) {
            if(n.getNodeType()==Node.ELEMENT_NODE) {
                if(headers==null)
                    headers = new HeaderList(ver);
                headers.add(Headers.create((Element)n));
            }
        }
    }

    // find the payload
    Element body = DOMUtil.getFirstChild(soapEnvelope, ver.nsUri, "Body");
    if(body==null)
        throw new WebServiceException("Message doesn't have <S:Body> "+soapEnvelope);
    Element payload = DOMUtil.getFirstChild(soapEnvelope, ver.nsUri, "Body");

    if(payload==null) {
        return new EmptyMessageImpl(headers, new AttachmentSetImpl(), ver);
    } else {
        return new DOMMessage(ver,headers,payload);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:35,代码来源:Messages.java

示例13: write

import org.w3c.dom.Element; //导入方法依赖的package包/类
protected void write(Element node) throws ShellException {
    printWriter.print('<');
    printWriter.print(node.getNodeName());
    Attr attrs[] = sortAttributes(node.getAttributes());
    for (int i = 0; i < attrs.length; i++) {
        Attr attr = attrs[i];
        printWriter.print(' ');
        printWriter.print(attr.getNodeName());
        printWriter.print("=\""); //$NON-NLS-1$
        normalizeAndPrint(attr.getNodeValue(), true);
        printWriter.print('"');
    }
    
    if (node.getChildNodes().getLength() == 0) {
        printWriter.print(" />"); //$NON-NLS-1$
        printWriter.flush();
    } else {
        printWriter.print('>');
        printWriter.flush();

        Node child = node.getFirstChild();
        while (child != null) {
            writeAnyNode(child);
            child = child.getNextSibling();
        }

        printWriter.print("</"); //$NON-NLS-1$
        printWriter.print(node.getNodeName());
        printWriter.print('>');
        printWriter.flush();
    }
}
 
开发者ID:ajtdnyy,项目名称:PackagePlugin,代码行数:33,代码来源:DomWriter.java

示例14: getElementText

import org.w3c.dom.Element; //导入方法依赖的package包/类
public static String getElementText(Element element) throws DOMException{
  for (Node child = element.getFirstChild(); child != null;
   child = child.getNextSibling()) {
    if(child.getNodeType() == Node.TEXT_NODE)
  return child.getNodeValue();
  }
  return element.getNodeValue();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:DOMUtils.java

示例15: testGetChild

import org.w3c.dom.Element; //导入方法依赖的package包/类
@Test
public void testGetChild() throws Exception {
    Document document = createDOMWithNS("ElementSample01.xml");
    Element elemNode = (Element) document.getElementsByTagName("b:aaa").item(0);
    elemNode.normalize();
    Node firstChild = elemNode.getFirstChild();
    Node lastChild = elemNode.getLastChild();
    assertEquals(firstChild.getNodeValue(), "fjfjf");
    assertEquals(lastChild.getNodeValue(), "fjfjf");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:ElementTest.java


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