本文整理了Java中org.w3c.dom.Element.getNodeType()
方法的一些代码示例,展示了Element.getNodeType()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.getNodeType()
方法的具体详情如下:
包路径:org.w3c.dom.Element
类名称:Element
方法名:getNodeType
暂无
代码示例来源:origin: groovy/groovy-core
/**
* Returns the list of any direct String nodes of this node.
*
* @return the list of String values from this node
* @since 2.3.0
*/
public static List<String> localText(Element self) {
List<String> result = new ArrayList<String>();
if (self.getNodeType() == Node.TEXT_NODE || self.getNodeType() == Node.CDATA_SECTION_NODE) {
result.add(self.getNodeValue());
} else if (self.hasChildNodes()) {
NodeList nodeList = self.getChildNodes();
for (int i = 0; i < nodeList.getLength(); i++) {
Node item = nodeList.item(i);
if (item.getNodeType() == Node.TEXT_NODE || item.getNodeType() == Node.CDATA_SECTION_NODE) {
result.add(item.getNodeValue());
}
}
}
return result;
}
代码示例来源:origin: robovm/robovm
if (this.getOwnerElement().getNodeType() == Node.ELEMENT_NODE) {
return getOwnerElement().lookupNamespaceURI(specifiedPrefix);
代码示例来源:origin: robovm/robovm
if (this.getOwnerElement().getNodeType() == Node.ELEMENT_NODE) {
return getOwnerElement().lookupNamespaceURI(specifiedPrefix);
代码示例来源:origin: robovm/robovm
if (this.getOwnerElement().getNodeType() == Node.ELEMENT_NODE) {
return getOwnerElement().lookupNamespaceURI(specifiedPrefix);
代码示例来源:origin: xalan/xalan
if (this.getOwnerElement().getNodeType() == Node.ELEMENT_NODE) {
return getOwnerElement().lookupNamespaceURI(specifiedPrefix);
代码示例来源:origin: xalan/xalan
if (this.getOwnerElement().getNodeType() == Node.ELEMENT_NODE) {
return getOwnerElement().lookupNamespaceURI(specifiedPrefix);
代码示例来源:origin: xalan/xalan
if (this.getOwnerElement().getNodeType() == Node.ELEMENT_NODE) {
return getOwnerElement().lookupNamespaceURI(specifiedPrefix);
代码示例来源:origin: robovm/robovm
if (this.getOwnerElement().getNodeType() == Node.ELEMENT_NODE) {
return getOwnerElement().lookupPrefix(namespaceURI);
代码示例来源:origin: robovm/robovm
if (this.getOwnerElement().getNodeType() == Node.ELEMENT_NODE) {
return getOwnerElement().lookupPrefix(namespaceURI);
代码示例来源:origin: robovm/robovm
if (this.getOwnerElement().getNodeType() == Node.ELEMENT_NODE) {
return getOwnerElement().lookupPrefix(namespaceURI);
代码示例来源:origin: xalan/xalan
if (this.getOwnerElement().getNodeType() == Node.ELEMENT_NODE) {
return getOwnerElement().lookupPrefix(namespaceURI);
代码示例来源:origin: xalan/xalan
if (this.getOwnerElement().getNodeType() == Node.ELEMENT_NODE) {
return getOwnerElement().lookupPrefix(namespaceURI);
代码示例来源:origin: xalan/xalan
if (this.getOwnerElement().getNodeType() == Node.ELEMENT_NODE) {
return getOwnerElement().lookupPrefix(namespaceURI);
代码示例来源:origin: stackoverflow.com
for (int i = 0; i < dataStreams.lenght(); i++) {
Element dataStream = (Element) dataStreams.item(i);
if (dataStream.getNodeType() == Element.ELEMENT_NODE) {
String title = dataStream.getAttributes()
.getNamedItem("title").getTextContent();
}
}
代码示例来源:origin: hypercube1024/firefly
@Override
public Element element(Element e, String name) {
NodeList element = e.getElementsByTagName(name);
if (element != null && e.getNodeType() == Node.ELEMENT_NODE) {
return (Element) element.item(0);
}
return null;
}
代码示例来源:origin: org.opensingular/singular-commons
/**
* @see org.w3c.dom.Node#getNodeType()
*/
public short getNodeType() {
return getCurrentInternal().getNodeType();
}
代码示例来源:origin: stackoverflow.com
HashMap<String, String> values = ...;
StringBuilder str = new StringBuilder();
for(Element child = ch1.getFirstChild; child != null; child = child.getNextSibling()) {
if(child.getNodeType() == Node.TEXT_NODE) {
str.append(child.getTextContent());
} else if(child.getNodeName().equals("value")) {
str.append(values.get(child.getAttributes().getNamedItem("name").getTextContent()));
}
}
String output = str.toString();
代码示例来源:origin: Microsoft/ApplicationInsights-Java
private static Element createMockElement(String attributeName, final String attributeValue) {
final Element mockElement = mock(Element.class);
Mockito.doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
return Node.ELEMENT_NODE;
}
}).when(mockElement).getNodeType();
addAttribute(mockElement, attributeName, attributeValue);
return mockElement;
}
代码示例来源:origin: epam/Wilma
@Test
public void testParseNodeShouldReturnEmptySetIfNodeTypeIsNotElementNode() {
//GIVEN
getChildNodes();
given(element.getNodeType()).willReturn(Node.COMMENT_NODE);
//WHEN
Set<ResponseFormatterDescriptor> actual = underTest.parseNode(node, document);
//THEN
assertTrue(actual.isEmpty());
}
代码示例来源:origin: epam/Wilma
@Test
public void testParseNodeShouldReturnTemplateFormatterParam() {
//GIVEN
getChildNodes();
given(element.getNodeType()).willReturn(Node.ELEMENT_NODE);
given(element.getTagName()).willReturn(TEMPLATE_FORMATTER_TAG);
mockTemplateFormatterAttributes();
//WHEN
Set<ResponseFormatterDescriptor> actual = underTest.parseNode(node, document);
//THEN
assertEquals(((ResponseFormatterDescriptor) actual.toArray()[0]).getParams().getAllParameters().get(0).getValue(), "value");
}
内容来源于网络,如有侵权,请联系作者删除!