Processing, 類XML
中的getChild()
用法介紹。
用法
.getChild(index)
.getChild(name)
參數
name
(String)
元素名稱或路徑/到/元素
返回
XML
說明
返回與name
參數匹配的元素的第一個子元素。名稱或路徑是一係列元素和子元素,以斜線分隔。
例子
PShape states;
PShape ohio;
void setup() {
size(100, 100);
states = loadShape("tristate.svg");
ohio = states.getChild("OH");
ohio.disableStyle();
}
void draw() {
background(0);
shape(states, -48, 5);
fill(102, 0, 0);
shape(ohio, -48, 5);
}
// The following short XML file called "mammals.xml" is parsed
// in the code below. It must be in the project's "data" folder.
//
// <?xml version="1.0"?>
// <mammals>
// <animal id="0" species="Capra hircus">Goat</animal>
// <animal id="1" species="Panthera pardus">Leopard</animal>
// <animal id="2" species="Equus zebra">Zebra</animal>
// </mammals>
XML xml;
void setup() {
xml = loadXML("mammals.xml");
XML firstChild = xml.getChild("animal");
println(firstChild.getContent());
}
// Sketch prints:
// Goat
相關用法
- Processing XML.getChildren()用法及代碼示例
- Processing XML.getContent()用法及代碼示例
- Processing XML.getString()用法及代碼示例
- Processing XML.getInt()用法及代碼示例
- Processing XML.getName()用法及代碼示例
- Processing XML.getParent()用法及代碼示例
- Processing XML.getFloat()用法及代碼示例
- Processing XML.getAttributeCount()用法及代碼示例
- Processing XML.getFloatContent()用法及代碼示例
- Processing XML.addChild()用法及代碼示例
- Processing XML.setString()用法及代碼示例
- Processing XML.listChildren()用法及代碼示例
- Processing XML.toString()用法及代碼示例
- Processing XML.setFloat()用法及代碼示例
- Processing XML.removeChild()用法及代碼示例
- Processing XML.setContent()用法及代碼示例
- Processing XML.setInt()用法及代碼示例
- Processing XML.format()用法及代碼示例
- Processing XML.listAttributes()用法及代碼示例
- Processing XML.hasChildren()用法及代碼示例
- Processing XML.hasAttribute()用法及代碼示例
- Processing XML.setName()用法及代碼示例
- Processing XML用法及代碼示例
- Processing FFT用法及代碼示例
- Processing SawOsc.pan()用法及代碼示例
注:本文由純淨天空篩選整理自processing.org大神的英文原創作品 XML.getChild()。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。