本文整理匯總了Java中org.dom4j.Element.nodeCount方法的典型用法代碼示例。如果您正苦於以下問題:Java Element.nodeCount方法的具體用法?Java Element.nodeCount怎麽用?Java Element.nodeCount使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.dom4j.Element
的用法示例。
在下文中一共展示了Element.nodeCount方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: read
import org.dom4j.Element; //導入方法依賴的package包/類
private static void read(Element e) {
String result = "";
if( !"".equals(targetPath) ){
return ;
}
if (e.nodeCount() > 0) {
Iterator<Element> it = e.elementIterator();
while (it.hasNext()) {
Element ele = it.next();
if( "CSVDataSet".equals(ele.getName()) ){
/*if("".equals(targetPath)){ //查到的第一個 CSVDataSet 保存到參數中,
targetPath = ele.getUniquePath();
}*/
targetPath = ele.getUniquePath();
}
read(ele);
}
}
}
示例2: treeWalk
import org.dom4j.Element; //導入方法依賴的package包/類
/**
* 遍曆解析元素
* @param element
*/
public void treeWalk(Element element) {
for ( int i = 0, size = element.nodeCount(); i < size; i++ ) {
Node node = element.node(i);
if ( node instanceof Element ) {
treeWalk( (Element) node );
}
else {
// 處理....
}
}
}
示例3: writeElement
import org.dom4j.Element; //導入方法依賴的package包/類
protected void writeElement(Element element) throws IOException {
int size = element.nodeCount();
String qualifiedName = element.getQualifiedName();
writePrintln();
indent();
writer.write("<");
writer.write(qualifiedName);
boolean textOnly = true;
for (int i = 0; i < size; i++) {
Node node = element.node(i);
if (node instanceof Element) {
textOnly = false;
} else if (node instanceof Comment) {
textOnly = false;
}
}
writeAttributes(element);
lastOutputNodeType = Node.ELEMENT_NODE;
if (size <= 0) {
writeEmptyElementClose(qualifiedName);
} else {
writer.write(">");
if (textOnly) {
// we have at least one text node so lets assume
// that its non-empty
writeElementContent(element);
} else {
if (element.attributeCount() > 3)
writePrintln();
// we know it's not null or empty from above
++indentLevel;
writeElementContent(element);
--indentLevel;
writePrintln();
indent();
}
writer.write("</");
writer.write(qualifiedName);
writer.write(">");
}
if (element.attributeCount() > 2 && indentLevel > 0)
writePrintln();
lastOutputNodeType = Node.ELEMENT_NODE;
}