0
我有這個DOMElement。如何從DOMElement獲取屬性
我有兩個問題:
1)什麼意思是指對象值被忽略?
2)如何從這個DOMElement獲取屬性?
object(DOMElement)#554 (18) {
["tagName"]=>
string(5) "input"
["schemaTypeInfo"]=>
NULL
["nodeName"]=>
string(5) "input"
["nodeValue"]=>
string(0) ""
["nodeType"]=>
int(1)
["parentNode"]=>
string(22) "(object value omitted)"
["childNodes"]=>
string(22) "(object value omitted)"
["firstChild"]=>
NULL
["lastChild"]=>
NULL
["previousSibling"]=>
string(22) "(object value omitted)"
["nextSibling"]=>
string(22) "(object value omitted)"
["attributes"]=>
string(22) "(object value omitted)"
["ownerDocument"]=>
string(22) "(object value omitted)"
["namespaceURI"]=>
NULL
["prefix"]=>
string(0) ""
["localName"]=>
string(5) "input"
["baseURI"]=>
NULL
["textContent"]=>
string(0) ""
}
我已經讓這個類訪問該對象。這樣做的目的是爲了能夠從輸入字段獲取類型屬性。
<?php
namespace App\Model;
class Field
{
/**
* @var \DOMElement
*/
protected $node;
public function __construct($node){
$this->node = $node;
}
public function getNode(){
return $this->node;
}
public function getTagName(){
foreach ($this->node as $value) {
return $value->tagName;
}
}
public function getAttribute(){
}
}