當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Processing XML.getParent()用法及代碼示例

Processing, 類XML中的getParent()用法介紹。

用法

  • .getParent()

返回

  • XML

說明

獲取元素父級的副本。將父對象作為另一個 XML 對象返回。

例子

// 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[] children = xml.getChildren("animal");
  XML parent = children[1].getParent();
  println(parent.getName());
}

// Sketch prints:
// mammals

相關用法


注:本文由純淨天空篩選整理自processing.org大神的英文原創作品 XML.getParent()。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。