<p>Anyone who writes client-side JavaScript is familiar with the DOM - the tree structure that your browser references in memory, generated from the HTML it got from the server. JavaScript can add, remove and modify nodes on the DOM tree to make changes to the page. I find it very nice to work with (browser bugs aside), and very different from the way my server-side code has to generate the page in the first place.</p>

<p>My question is: what server-side frameworks/languages build a page by treating it as a DOM tree from the beginning - inserting nodes instead of echoing strings? I think it would be very helpful if the client-side and server-side code both saw the page the same way. You could certainly hack something like this together in any web server language, but a framework dedicated to creating a page this way could make some very nice optimizations.</p>

<p>Open source, being widely deployed and having been around a while would all be pluses.</p>

[{'answer_id': 14914, 'author': 'Andrew Taylor', 'author_id': 1776, 'author_profile': 'https://Stackoverflow.com/users/1776', 'pm_score': -1, 'selected': False, 'text': "<p>I see where you're coming from but it's all a bit moot isn't it. You can't send anything but rendered content to the browser, and you have to do it all in one go (AJAX aside). There's no value from what you are suggesting (from what I can see) as even if you build it tree-like, you're still only building a page which is sent wholesale to the client.</p>\n"}, {'answer_id': 14921, 'author': 'eplawless', 'author_id': 1370, 'author_profile': 'https://Stackoverflow.com/users/1370', 'pm_score': 3, 'selected': True, 'text': '<p>You\'re describing <a href="http://www.youtube.com/watch?v=1QD9XQm_Jd4" rel="nofollow noreferrer">Rhino on Rails</a>, which is not out but will be soon.\nSimilarly, <a href="http://www.aptana.com/jaxer/" rel="nofollow noreferrer">Aptana Jaxer</a>, however RnR will include an actual framework (Rails) whereas  Jaxer is just the server technology.</p>\n'}, {'answer_id': 14927, 'author': 'Brian Warshaw', 'author_id': 1344, 'author_profile': 'https://Stackoverflow.com/users/1344', 'pm_score': 2, 'selected': False, 'text': "<p>Aptana's Jaxer AJAX server might be something for you to check out, as it uses JS server-side, as well.</p>\n\n<p>That being said, I would argue that you're better off not generating your markup with print statements or echos, but rather template and hook in your dynamic content. </p>\n"}, {'answer_id': 973352, 'author': 'Olivvv', 'author_id': 113291, 'author_profile': 'https://Stackoverflow.com/users/113291', 'pm_score': 0, 'selected': False, 'text': '<p>Jaxer is server-side javascript + the DOM. You can integrate jaxer with other languages, by post-processing their output.</p>\n\n<p>Also in java, php, ...   you can use xpath to manipulate the DOM. </p>\n'}]
['https://Stackoverflow.com/questions/14909', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/619/']