Say the following HTML is part of a webpage -
<div id='container'>
<div class='inner'>
<p id='text_a'>Some text</p>
<p id='text_b'>Some more text</p>
</div>
</div>
Say I save this HTML into a string and send it to a server. Is it possible then to interact with this HTML on the server using a DOM? So that I can do something like .getElementById('text_a').value to retrieve 'Some text'? And following on, would it be possible to use jQuery to interact with the HTML?
Check out cheerio. From the readme:
var cheerio = require('cheerio'),
$ = cheerio.load('<h2 class="title">Hello world</h2>');
$('h2.title').text('Hello there!');
$('h2').addClass('welcome');
$.html();
//=> <h2 class="title welcome">Hello there!</h2>
There's also jsdom, but cheerio is simpler and comes with jquery-like goodness.
The DOMDocument class
http://php.net/manual/en/class.domdocument.php
3rd party
PHP Simple HTML DOM Parser Manual