• Sorular
  • Etiketler

DOMDocument &

1 Cevap php

Kullanarak aşağıdaki PHP kodu verilen DOMDocument :

$inputs = $xpath->query('//input | //select | //textarea', $form);

if ($inputs->length > 0)
{
    for ($j = 0; $j < $inputs->length; $j++)
    {
    	$input = $inputs->item($j);

    	$input->getAttribute('name'); // Returns the Attribute
    	$input->getTag(); // How can I get the input, select or textarea tag?
    }
}

Nasıl her eşleşen düğümün etiket adını bilebilir?

1 Cevap

$inputs = $xpath->query('//input | //select | //textarea', $form);

// no need for "if ($inputs->length > 0) - the for loop won't run if it is 0
for ($j = 0; $j < $inputs->length; $j++)
{
  $input = $inputs->item($j);
  echo $input->nodeName;
}

Bkz: http://www.php.net/manual/en/class.domnode.php#domnode.props.nodename

PS: Apart dokümanlar içine bakarak, bir var_dump() gerçekten yararlı olabilir.

0

etiketler

  • php
  • dom
  • xhtml
  • Sorular
  • Etiketler
Copyright © 2014

Powered by EvrenWeb Int. Media.