getElementById for php possible?

Is getElementById for php possible?

What’s this:
http://ca2.php.net/manual/en/function.domdocument-get-element-by-id.php

Why not?
What forbids PHP from reading a text file, parse it into DOM structure and then search this structure for the certain element?

I don’t understand how that works though.
Is this how you write it?
domelement DomDocument->get_element_by_id ( string $id )

See here. Plenty of good examples for you. :slight_smile:

mmm… I think you’re confused. Tell us what you are trying to accomplish and we may be able to better help. Are you trying to get the value of a form element? Or are you trying to lift content off an existing page fetched via php?

I was thinking of using a for loop in php. The amount of cycles would vary by the getElementById of the following select tag value:

<table>
 
    <tbody><tr>
        <td>
        <select id="ta" name="ta" onchange="changeTa();">
            <option selected="selected" value="">How Many Textareas?</option>
            <option value="3">3 Textareas</option>
            <option value="5">5 Textareas</option>
            <option value="10">10 Textareas</option>
 
            <option value="20">20 Textareas</option>
            <option id="taall" value="all">All Textareas</option>
        </select>
        </td>
    </tr>
<tr><td>
<textarea id="txtarea_0" rows="6" cols="20" name="txtar0" style="border: 1px solid Red; margin: 5px; padding: 0px 5px; float: left; width: 150px; height: 70px; color: Red; font-weight: bold;"></textarea>
    <input value=" Clear txtarea_0 " onclick="tArea0();" style="border-color: Red; margin: 5px; float: left; background-color: Red; color: rgb(255, 255, 255); font-weight: bold; font-size: 12px;" type="Reset">
 
</td></tr>
<tr><td>
<textarea id="txtarea_1" rows="6" cols="20" name="txtar1" style="border: 1px solid Blue; margin: 5px; padding: 0px 5px; float: left; width: 150px; height: 70px; color: Blue; font-weight: bold;"></textarea>
    <input value=" Clear txtarea_1 " onclick="tArea1();" style="border-color: Blue; margin: 5px; float: left; background-color: Blue; color: rgb(255, 255, 255); font-weight: bold; font-size: 12px;" type="Reset">
</td></tr>
<tr><td>
<textarea id="txtarea_2" rows="6" cols="20" name="txtar2" style="border: 1px solid Green; margin: 5px; padding: 0px 5px; float: left; width: 150px; height: 70px; color: Green; font-weight: bold;"></textarea>
    <input value=" Clear txtarea_2 " onclick="tArea2();" style="border-color: Green; margin: 5px; float: left; background-color: Green; color: rgb(255, 255, 255); font-weight: bold; font-size: 12px;" type="Reset">
</td></tr>
</tbody></table>

Does it have to be an xml file?

<?php

$doc = new DomDocument;

// We need to validate our document before refering to the id
$doc->validateOnParse = true;
$doc->Load('book.xml');

echo "The element whose id is books is: " . $doc->getElementById('books')->tagName . "\
";

?>

I need to use the open file to look for ids. I don’t want to load an external file.