The XMLReader::moveToElement() function is an inbuilt function in PHP which is used to move cursor to the parent element of current attribute. This function can be used to get the element having certain attributes by combining this with XMLReader::moveToAttribute() function.
bool XMLReader::moveToElement( void )
Parameters: This function doesn’t accepts any parameter.
Return Value: This function returns TRUE if successful and FALSE if it fails or not positioned on attribute when this method is called.
Below given programs illustrate the XMLReader::moveToElement() function in PHP:
Program 1: In this program, we will get the name of element having attribute “attrib”
Program 2: In this program, we will get the name of all elements having attribute “attrib”.