本文整理了Java中de.pdark.decentxml.Document.getChild()
方法的一些代码示例,展示了Document.getChild()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Document.getChild()
方法的具体详情如下:
包路径:de.pdark.decentxml.Document
类名称:Document
方法名:getChild
暂无
代码示例来源:origin: de.pdark/decentxml
public Element getChild (String path)
{
return getChild (path, null);
}
代码示例来源:origin: stackoverflow.com
Document doc = new Document(MyDir + "document.docx");
// Retrieve the first table in the document.
Table table = (Table)doc.getChild(NodeType.TABLE, 0, true);
// Clone the last row in the table.
Row clonedRow = (Row)table.getLastRow().deepClone(true);
// Remove all content from the cloned row's cells. This makes the row ready for
// new content to be inserted into.
for (Cell cell: clonedRow.getCells())
{
cell.getFirstParagraph().getRuns().clear();
cell.getFirstParagraph().appendChild(new Run(doc,"hello text"));
}
// Add the row to the end of the table.
table.appendChild(clonedRow);
doc.save(MyDir + "Table.AddCloneRowToTable Out.doc");
代码示例来源:origin: stackoverflow.com
//Load the document
Document doc = new Document(MyDir + "in.docx");
//Get the first table in the document
Table table = (Table)doc.getChild(NodeType.TABLE, 0, true);
//Get the first cell of first row
Cell cell = (Cell)table.getRows().get(0).getCells().get(0);
//Change the color of text
for (Run run : (Iterable<Run>)cell.getChildNodes(NodeType.RUN, true))
{
run.getFont().setColor(Color.BLUE);
}
//Save the document
doc.save(MyDir + "Out.docx");
代码示例来源:origin: stackoverflow.com
Document doc = new Document(MyDir + "in.docx");
DocumentBuilder builder = new DocumentBuilder(doc);
Table table = (Table)doc.getChild(NodeType.TABLE, 0, true);
Cell cell = table.getFirstRow().getFirstCell();
builder.moveTo(cell.getFirstParagraph());
FieldBuilder fbuilder = new FieldBuilder(FieldType.FIELD_FORMULA);
fbuilder.addArgument("20000").addSwitch("\\# \"#,##0\"").buildAndInsert(builder.getCurrentParagraph());
doc.updateFields();
doc.save(MyDir + "Out.docx");
代码示例来源:origin: eclipse/tycho
public static IU read(File file) throws IOException {
FileInputStream is = new FileInputStream(file);
try {
Document iuDocument = parser.parse(new XMLIOSource(is));
Element root = iuDocument.getChild(UNIT);
if (root == null)
throw new RuntimeException("No iu found.");
IU result = new IU(iuDocument, root);
if (result.getId() == null)
throw new RuntimeException(
String.format("The IU defined in %s is missing an id.", file.getAbsolutePath()));
if (result.getVersion() == null)
throw new RuntimeException(
String.format("The IU defined in %s is missing a version.", file.getAbsolutePath()));
return result;
} finally {
IOUtil.close(is);
}
}
代码示例来源:origin: org.eclipse.tycho/tycho-metadata-model
public static IU read(File file) throws IOException {
FileInputStream is = new FileInputStream(file);
try {
Document iuDocument = parser.parse(new XMLIOSource(is));
Element root = iuDocument.getChild(UNIT);
if (root == null)
throw new RuntimeException("No iu found.");
IU result = new IU(iuDocument, root);
if (result.getId() == null)
throw new RuntimeException(
String.format("The IU defined in %s is missing an id.", file.getAbsolutePath()));
if (result.getVersion() == null)
throw new RuntimeException(
String.format("The IU defined in %s is missing a version.", file.getAbsolutePath()));
return result;
} finally {
IOUtil.close(is);
}
}
代码示例来源:origin: de.pdark/decentxml
return doc == null ? null : doc.getChild (path, ns);
代码示例来源:origin: io.provis/provisio-jenkins
private boolean mergeDoc(Document from, Document to) {
Element rootFrom = from.getRootElement();
String appendPath = rootFrom.getAttributeValue("appendPath");
if (appendPath != null) {
return appendPath(rootFrom, to, appendPath);
}
String replacePath = rootFrom.getAttributeValue("replacePath");
if (replacePath != null) {
return replacePath(rootFrom, to, replacePath);
}
Element rootTo;
String mergePath = rootFrom.getAttributeValue("mergePath");
if (mergePath != null) {
Element child = to.getChild(mergePath);
if (child == null) {
throw new IllegalStateException("Cannot merge " + name + " to path " + mergePath);
}
rootTo = child;
} else if (rootFrom.getName().equals(to.getRootElement().getName())) {
rootTo = to.getRootElement();
} else {
return false;
}
merge(rootFrom, rootTo);
return true;
}
内容来源于网络,如有侵权,请联系作者删除!