本文整理匯總了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);
}