How to get the NodeValue from <td> type input

I am using this HTML and I am trying to parse it to get the nodeValue of all the elements in the table columns.

<table id="custinfo">
        <td><label>First Name</label></td> 
        <td><input type="text" name="firstname" ></td>    
        <td><label>Last Name</label></td>
        <td><input type="text" name="lastname" ></td>   
        <td><label>Phone Number</label></td> 
        <td><input type="text" name="email" ></td>

Here is the PHP It's only working for the labels but not for the input types.

$Dom= new DOMDocument();   
$input_tags = $dom->getElementsByTagName('input'); 
$fname=$fnamecol->item(1)->nodeValue; //this is returning null Instead of returning the input text value.

Use simple_dom_parser.php library instead (Download library: & docs:


// Create DOM from file
$html = file_get_html('Pre_order.html');

// Find all labels
foreach($html->find('label') as $label)
       echo $label->plaintext . '<br>';

// Find all inputs
foreach($html->find('input') as $input)
       echo $input->name . '<br>';