如何从PHP中的HTML字符串中提取数据

I have got the follwing HTML string in which i need to access the value of a specific id .

The string is as follows

<form name="aspnetForm" method="post" action="userview.aspx" id="aspnetForm">
    <div>
    <input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
    <input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
    <input type="hidden" name="__LASTFOCUS" id="__LASTFOCUS" value="" />
    <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="test_value" />
    </div>

Now in order to access it i have written the following code

$doc = new DOMDocument();
    @$doc->loadHTML($str);
    $finder = new DomXPath($doc);
    $spanner = $finder->query("//*[contains(@id, '__VIEWSTATE')]");
    foreach ($spanner as $node) 
        {
             echo $node->nodeValue;
        }

where str is my string. Now every time i run it , it returns a blank value

</div>

Try this in this query part has modified

$html = '<form name="aspnetForm" method="post" action="userview.aspx" id="aspnetForm">
<div>
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
<input type="hidden" name="__LASTFOCUS" id="__LASTFOCUS" value="" />
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="adsadsadsdsadsd" />
</div>';
 $doc = new DOMDocument;
 $doc->loadHTML($html);
 $xpath = new DOMXpath($doc);
 $val= $xpath->query('//input[@type="hidden" and @id = "__VIEWSTATE"]/@value' 
 );
print_r($val[0]->nodeValue);