I think part one in my do it yourself proposal, is independant of language, since
"The Document Object Model is a platform- and language-neutral interface that will allow programs and scripts to dynamically access and update the content, structure and style of documents. The document can be further processed and the results of that processing can be incorporated back into the presented page. This is an overview of DOM-related materials here at W3C and around the web".
Source:
W3C Document Object Model
I have never used and know nothing about inbuilt functions in that language, so I can not help you more. May be you may write the function yourself.