Anti-nuisance lawsuit warning: The purpose of these notes is to remind me, Zoegond, of stuff or to help me work stuff out. They may contain mistakes.

Quick

  • ($a, $b....) = unpack("A2A7...", $packed)
  • push( array, list )

Saturday, June 16, 2012

DOM basics & gotchas

Get element attributes with .getAttribute(attrname). Element tag names in .tagName - in upper case seemingly. (tagName is a property of Element btw, not HTMLElement or Node. But className is a property of HTMLElement, presumably because HTML elements are expected to have 'class' whereas SGML ones aren't, necessarily. Not that this matters in practical terms.)

You can supply an XPath evaluation with a context node by supplying that node in the contextnode parameter. That node will then be the one represented by "." in the XPath expression.

NodeList is returned by childNodes and the getElementsBy... methods among others. It takes .item() or [] and has .length . If there are no nodes to return, you get an empty NodeList (not null).

Followers

Blog Archive