ElementGetElementsByTagNameNSpublic final class ElementGetElementsByTagNameNS extends DOMTestCase The method getElementsByTagNameNS returns a NodeList of all the Elements with
a given local name and namespace URI in the order in which they are
encountered in a preorder traversal of the Document tree. Invoke
getElementsByTagNameNS on the documentElement with values for namespaceURI
'*' and localName '*'. Verify if this returns a nodeList of 0 elements. |
Fields Summary |
---|
DOMDocumentBuilderFactory | factory | DocumentBuilder | builder |
Methods Summary |
---|
protected void | setUp()
super.setUp();
try {
factory = new DOMDocumentBuilderFactory(DOMDocumentBuilderFactory
.getConfiguration2());
builder = factory.getBuilder();
} catch (Exception e) {
fail("Unexpected exception" + e.getMessage());
}
| protected void | tearDown()
factory = null;
builder = null;
super.tearDown();
| public void | testGetElementsByTagNameNS1()Runs the test case.
Document doc;
Element element;
NodeList elementList;
doc = (Document) load("staffNS", builder);
element = doc.getDocumentElement();
elementList = element.getElementsByTagNameNS("**", "*");
assertEquals("elementgetelementsbytagnamens02", 0, elementList
.getLength());
| public void | testGetElementsByTagNameNS4()
Document doc;
Element element;
Element child1;
Element child2;
Element child3;
NodeList elementList;
String nullNS = null;
doc = (Document) load("staffNS", builder);
element = doc.createElementNS("http://www.w3.org/DOM", "root");
child1 = doc.createElementNS("http://www.w3.org/DOM/Level1",
"dom:child");
child2 = doc.createElementNS(nullNS, "child");
child3 = doc.createElementNS("http://www.w3.org/DOM/Level2",
"dom:child");
element.appendChild(child1);
element.appendChild(child2);
element.appendChild(child3);
elementList = element.getElementsByTagNameNS(nullNS, "child");
assertEquals("elementgetelementsbytagnamens04_1", 1, elementList
.getLength());
elementList = element.getElementsByTagNameNS("*", "child");
assertEquals("elementgetelementsbytagnamens04_2", 3, elementList
.getLength());
| public void | testGetElementsByTagNameNS5()
Document doc;
Element element;
NodeList elementList;
doc = (Document) load("staffNS", builder);
element = doc.getDocumentElement();
elementList = element.getElementsByTagNameNS(
"http://www.altavista.com", "*");
assertEquals("elementgetelementsbytagnamens05", 1, elementList
.getLength());
|
|