locationId !== null ) { return $this->locationId; } // If we did not reach the root node yet, request the parent location // id to prepend to generated ID: $locationId = ''; if ( !$this->parentNode instanceof DOMDocument ) { $locationId = $this->parentNode->getLocationId(); } // Append current node information $locationId .= '/' . $this->tagName; // Check for relevant attributes, so that they are also included foreach ( $this->relevantAttributes as $attribute ) { if ( $this->hasAttribute( $attribute ) ) { $locationId .= '[' . $attribute . '=' . preg_replace( '([^a-z0-9_-]+)', '_', strtolower( $this->getAttribute( $attribute ) ) ) . ']'; } } // Append class, if set if ( $this->hasAttribute( 'class' ) ) { $locationId .= '.' . preg_replace( '([^a-z0-9_-]+)', '_', strtolower( $this->getAttribute( 'class' ) ) ); } // Append ID, if set if ( $this->hasAttribute( 'ID' ) ) { $locationId .= '#' . preg_replace( '([^a-z0-9_-]+)', '_', strtolower( $this->getAttribute( 'ID' ) ) ); } return $locationId; } } ?>