Java 8 NodeList - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 NodeList class.

This code example shows how to use the following methods:getLength, item
This code example shows how to use the following methods:getLength, item
  public void testTwoNewPages() throws Exception {
    String recentChangeOne = "|MyNewPage|me|" + date + "|";
    String recentChangeTwo = "|SomeOtherPage||" + date + "|";
    String recentChangesContent = recentChangeOne + "\n" + recentChangeTwo + "\n";
    NodeList items = getReportedItems(recentChangesContent);
    assertEquals(2, items.getLength());
    checkItem(items.item(0), "MyNewPage", "me", rfcDate, "me:" + rfcDate, "http://" + hostName + "/MyNewPage");
    checkItem(items.item(1), "SomeOtherPage", null, rfcDate, rfcDate, "http://" + hostName + "/SomeOtherPage");
  } 
 
  @Test
  public void testReportedPagesSelectedByResource() throws Exception {
    request.setResource("FrontPage"); 
    String page1 = "|SomePage|me|" + date + "|";
    String page2 = "|FrontPage|me|" + date + "|";
    String page3 = "|FrontPage.MyPage|me|" + date + "|";
    String page4 = "|SomePage.FrontPage|me|" + date;
 
    String recentChangesContent = page1 + "\n" + page2 + "\n" + page3 + "\n" + page4 + "\n";
    NodeList items = getReportedItems(recentChangesContent);
8
CodeRank
This code example shows how to use the following methods:item
    return Float.parseFloat(val);
  } 
 
  public static String getXmlString(Element element, String name) {
    NodeList id = element.getElementsByTagName(name);
    Element line = (Element) id.item(0);
    if (line == null) {
      return null; 
    } 
    Node first = line.getFirstChild();
    // handle empty <key></key> 
    if (first == null) {
      return ""; 
    } 
    String val = first.getNodeValue();
    if (val == null) {
      return ""; 
    } 
    return val;
  } 
8
CodeRank
This code example shows how to use the following methods:getLength, item
This code example shows how to use the following methods:getLength
        Document doc;
        NodeList newList;
        doc = (Document) load("staffNS", builder);
        newList = doc.getElementsByTagNameNS(namespaceURI, localName);
        // BEGIN android-changed: Was 37, but that assumed validation. 
        assertEquals("throw_Size", 36, newList.getLength());
        // END android-changed 
    } 
    public void testGetElementsByTagNameNS2() throws Throwable { 
        Document doc;
        NodeList newList;
        Element newElement;
        String prefix;
        String lname;
        doc = (Document) load("staffNS", builder);
        newList = doc.getElementsByTagNameNS("*", "employee");
        assertEquals("employeeCount", 5, newList.getLength());
        newElement = (Element) newList.item(3);
        prefix = newElement.getPrefix();
        assertEquals("prefix", "emp", prefix);
7
CodeRank
This code example shows how to use the following methods:getLength
This code example shows how to use the following methods:getLength, item
                Element surface = mDom.getElementById(surfaceName);
                if (surface == null) {
                    return null; 
                } 
                nl = surface.getElementsByTagName("init_from");
                if (nl != null && nl.getLength() == 1) {
                    ref = (Element)nl.item(0);
                    texName = getString(ref);
                } 
            } 
        } 
 
        //Log.v(TAG, "Extracted texture name " + texName); 
        return mImages.get(texName);
    } 
 
    void extractParams(Element fx, ArrayList<ShaderParam> params) {
        Node paramNode = fx.getFirstChild();
        while (paramNode != null) {
            if (paramNode.getNodeType() == Node.ELEMENT_NODE) {
8
CodeRank
This code example shows how to use the following methods:item
		XpathEngine engine = XMLUnit.newXpathEngine();
		engine.setNamespaceContext(ctx);
 
		Document doc = XMLUnit.buildControlDocument(xmlDoc);
		NodeList node = engine.getMatchingNodes(xpath, doc);
		assertEquals(msg, expected, node.item(0).getNodeValue());
	} 
 
	/** 
	 * Creates a instance of {@link CastorObject} for testing. 
	 * 
	 * @return a instance of {@link CastorObject} 
	 */ 
	private CastorObject createCastorObject() { 
		CastorObject castorObject = new CastorObject();
		castorObject.setName("test");
		castorObject.setValue(8);
		return castorObject;
	} 
} 
7
CodeRank
This code example shows how to use the following methods:item
        String resultNamespaceURI;
        String resultLocalName;
        String resultPrefix;
        doc = (Document) load("staffNS", builder);
        elementList = doc.getElementsByTagName("emp:address");
        testAddr = elementList.item(0);
        assertNotNull("empAddrNotNull", testAddr);
        ((Element) /* Node */testAddr).setAttributeNS("http://www.nist.gov",
                "newprefix:zone", "newValue"); 
        addrAttr = ((Element) /* Node */testAddr).getAttributeNodeNS(
                "http://www.nist.gov", "zone"); 
        resultAttr = ((Element) /* Node */testAddr).getAttributeNS(
                "http://www.nist.gov", "zone"); 
        assertEquals("attrValue", "newValue", resultAttr);
        resultNamespaceURI = addrAttr.getNamespaceURI();
        assertEquals("nsuri", "http://www.nist.gov", resultNamespaceURI);
        resultLocalName = addrAttr.getLocalName();
        assertEquals("lname", "zone", resultLocalName);
        resultPrefix = addrAttr.getPrefix();
        assertEquals("prefix", "newprefix", resultPrefix);
7
CodeRank
This code example shows how to use the following methods:getLength, item
 
        // Check to see if the image file is hidden by a sampler surface link combo 
        Element sampler = mDom.getElementById(samplerName);
        if (sampler != null) {
            NodeList nl = sampler.getElementsByTagName("source");
            if (nl != null && nl.getLength() == 1) {
                Element ref = (Element)nl.item(0);
                String surfaceName = getString(ref);
                if (surfaceName == null) {
                    return null; 
                } 
 
                Element surface = mDom.getElementById(surfaceName);
                if (surface == null) {
                    return null; 
                } 
                nl = surface.getElementsByTagName("init_from");
                if (nl != null && nl.getLength() == 1) {
                    ref = (Element)nl.item(0);
                    texName = getString(ref);
7
CodeRank

Related Java 8 NodeList Questions & Answers:

Other Java 8 NodeList Examples

1:		NodeList n = item.getElementsByTagName(str);		
2:		return this.getElementValue(n.item(0));
3:	}

Read More

28:	
29:						NodeList nl = doc.getElementsByTagName(KEY_ITEM);
30:						// looping through all item nodes <item>
31:						for (int i = 0; i < nl.getLength(); i++) {
32:							// creating new HashMap

Read More

10:	Document doc = parser.getDomElement(xml); // getting DOM element
11:	
12:	NodeList nl = doc.getElementsByTagName(KEY_ITEM);
13:	
14:	// looping through all item nodes <item>

Read More

See Code Examples for Java 8 NodeList Methods: