PHP Conference Japan 2024

XMLReader::moveToElement

(PHP 5 >= 5.1.0, PHP 7, PHP 8)

XMLReader::moveToElement將游標定位到目前屬性的父元素

說明

public XMLReader::moveToElement(): bool

將游標移動到目前屬性的父元素。

參數

此函式沒有參數。

回傳值

成功則回傳 true,如果失敗或在此方法被呼叫時未定位在屬性上則回傳 false

參見

新增筆記

使用者貢獻的筆記 1 則筆記

Sean Colin Ruiz
7 年前
在像這樣的元素上:<self_closing attribute="1" /> 遍歷屬性後,isEmptyElement 會返回 FALSE。因此,您需要隱式調用 moveToElement(),以便將游標移回父元素並再次使用 isEmptyElement。
To Top