开发者

XPath: Parent form of submit button

I want to use PHP and DomXPath::query to get the parent "form" element of a submit button. The variable $dom holds the complete DOM tree and $node represents the submit button as a DOM node.

$query = '??????';
$xpath = new \DomXPath( $dom );

$parents = $xpath->query( $query, $node );

if ( $parents->length )
{

    $form = $parents->item( 0 );

}

I tried several queries, but until now I found no solution. I think it would开发者_Go百科 be easy if I had more time to read about that XPath syntax. I hope you can help. :)


$query = 'ancestor::form';

This assumes the submit button only has one ancestor that is a form (you cannot nest forms in HTML).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜