Published  Feb 07, 2014
Updated  Feb 07, 2014
0  3


HTML DOM for mIRC ( $dom )
Written by PennyBreed @ on #botdev

This set of aliases will allow you to retrieve, query and traverse HTML DOM
using an InternetExplorer instance. The calls support nesting, example:

This was my primary goal with my $xml script, before I realized it would not accept
malformed HTML, but finished it anyway. These scripts basically simplify the $com calls
and provide a quick way to clean them up, using /dom_free and /dom_freeall


The lookups are slow, since it waits for the page to load in
IE. Furthermore, this won't handle multiple lookups in a
single instance. Once you've used $dom_open to load a new page,
it's child objects no longer exist. Personally, I think the lookups
are slow enough without the need for multiple instances of IE.


3.04 KB
Feb 07, 2014


Sign in to comment.
SReject   -  Apr 11, 2014

Instead of loading the page in IE, I THINK you can com into ms's DOM handler, and specify a page or local file instead of requiring IE to download and parse the page. Will report back if I find what I'm looking for. Also, mmmm coms!


Found what I was looking for: msxml2.DOMDocument.6.0, After creating the com, you can load xml/html locally instead of requiring the use of IE to download the file.

If you want to download a page, then traverse the DOM, you can use msxml2.xmlhttp or similar to get the page, then use msxml2.DOMDocument to parse what's downloaded. It should be quite a bit faster than using InternetExplorer.Application to download and parse the page/file into a usable DOM

msxml2.DOMDocument Object Reference:
msxml.xmlhttp Object Reference:

PennyBreed  -  Apr 11, 2014

These don't accept malformed HTML, and always throw parsing errors. I actually started out using these, before I recognized that. I saved the old code and made it strictly for XML, but have not posted it yet. I've not really been doing any msl. Furthermore, loading them in IE allows you to wait until the page is loaded, and access information filled by javascript or other means.

SReject  -  Apr 12, 2014

Ah very nice then! Though, I could have sworn there was a property/argument for DOMDocument to accept/correct 'malformed' html/xml

SReject  -  Apr 12, 2014

Soo, after a bit of researching and some hit and miss coding, I think I have something of interest. Instead of using DOMDocument, have you tried htmlfile. It allows for malformed html and xml, while still giving the ability to load a file locally.

I haven't researched too much into to see if it can get and process a remote file + javascript, but here's a simple test alias as an example:

; /domLoad ComName random HTML Code 
alias domLoad {
  comopen $1 htmlfile
  var %page = $1 $+ page
  if ($comerr) {
    echo -a :: comerr on open
  elseif (!$com($1,open,1)) || $comerr) {
    echo -a :: comerr when opening htmlfile
  elseif (!$com($1,write,1,bstr, $2-) || $comerr) {
    echo -a :: comerr when writing htmlfile
  elseif (!$com($1,close,1) || $comerr) {
    echo -a :: comerr when closing htmlfile
      This is just for testing purposes.
      From here you could start using getElement*By*()
      methods or similar

  elseif (!$com($1, body, 2, dispatch* %page) || $comerr) {
    echo -a :: comerr when retriving body
  elseif (!$com(%page, innerHTML, 2) || $comerr) {
    echo -a :: comerr when retriving innerHTML of body
  else {
    echo -a :: $com(%page).result
  comclose $1
  comclose %page

I'd like to apologize if I've come off as being smug or snobbish while commenting (attitudes don't get transferred with text), my intentions were to be insightful and give feedback, not to be egotistical or arrogant.

Sign in to comment

ProIcons   -  Feb 11, 2014

Good Job,

PennyBreed  -  Feb 12, 2014


Sign in to comment

Hawkee   -  Feb 07, 2014

Very practical script.

PennyBreed  -  Feb 07, 2014

Thanks, Hawkee :)

Sign in to comment

Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.