本文整理汇总了Java中org.w3c.dom.Text.getNodeValue方法的典型用法代码示例。如果您正苦于以下问题:Java Text.getNodeValue方法的具体用法?Java Text.getNodeValue怎么用?Java Text.getNodeValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.w3c.dom.Text
的用法示例。
在下文中一共展示了Text.getNodeValue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findText
import org.w3c.dom.Text; //导入方法依赖的package包/类
/**
* Extract nested text from an element.
* Currently does not handle coalescing text nodes, CDATA sections, etc.
* @param parent a parent element
* @return the nested text, or null if none was found
*/
static String findText(Element parent) {
NodeList l = parent.getChildNodes();
for (int i = 0; i < l.getLength(); i++) {
if (l.item(i).getNodeType() == Node.TEXT_NODE) {
Text text = (Text)l.item(i);
return text.getNodeValue();
}
}
return null;
}
示例2: findText
import org.w3c.dom.Text; //导入方法依赖的package包/类
/**
* Extract nested text from a node.
* Currently does not handle coalescing text nodes, CDATA sections, etc.
* @param parent a parent element
* @return the nested text, or null if none was found
*
* @since 8.4
*/
public static String findText(Node parent) {
NodeList l = parent.getChildNodes();
for (int i = 0; i < l.getLength(); i++) {
if (l.item(i).getNodeType() == Node.TEXT_NODE) {
Text text = (Text) l.item(i);
return text.getNodeValue();
}
}
return null;
}
示例3: getOuterXml
import org.w3c.dom.Text; //导入方法依赖的package包/类
protected void getOuterXml(StringBuffer sb)
{
// I think the XML standard says that newlines in text are converted from their
// local encoding to "\n". Java does that, but .Net does not, so here we put 'em back.
Text txt = getText();
String nodeValue = txt.getNodeValue();
if(nodeValue != null){
nodeValue = nodeValue.replace("\n", System.getProperty("line.separator"));
sb.append(StringSupport.encodeHTML(nodeValue));
}
}
示例4: addText
import org.w3c.dom.Text; //导入方法依赖的package包/类
private void addText(Text text) {
if (ignoreBlankText) {
String contents = text.getNodeValue();
contents = contents.trim();
if (contents.isEmpty()) {
return;
}
}
textNodes.add(text);
}