本文整理匯總了Java中org.w3c.dom.Text.setNodeValue方法的典型用法代碼示例。如果您正苦於以下問題:Java Text.setNodeValue方法的具體用法?Java Text.setNodeValue怎麽用?Java Text.setNodeValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.w3c.dom.Text
的用法示例。
在下文中一共展示了Text.setNodeValue方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: replaceText
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
*/
private static void replaceText(Element parent, String name) {
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);
text.setNodeValue(name);
return;
}
}
}
示例2: replaceText
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
*/
private static void replaceText(Element parent, String name) {
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);
text.setNodeValue(name);
return;
}
}
}
示例3: rewriteStyle
import org.w3c.dom.Text; //導入方法依賴的package包/類
public void rewriteStyle(Element elt){
try {
NodeList list = xpathApi.selectNodeList(elt, ".//STYLE/text()");
for(int j=0;j<list.getLength();j++){
if(list.item(j) instanceof Text){
Text node = (Text)list.item(j);
node.setNodeValue(rewriteStyle(node.getNodeValue()));
}
}
} catch (TransformerException e) {
Engine.logEngine.trace("WebClipper cannot evaluate STYLE node");
}
}