You are here

function mimemail_compress::calculateXPath in Mime Mail 6

Same name and namespace in other branches
  1. 7 modules/mimemail_compress/mimemail_compress.inc \mimemail_compress::calculateXPath()
1 call to mimemail_compress::calculateXPath()
mimemail_compress::compress in modules/mimemail_compress/mimemail_compress.inc

File

modules/mimemail_compress/mimemail_compress.inc, line 236
Converts CSS styles into inline style attributes.

Class

mimemail_compress
Compress HTML and CSS into combined message.

Code

function calculateXPath(DOMNode $node) {
  $xpath = '';
  $q = new DOMXPath($node->ownerDocument);
  do {
    $position = 1 + $q
      ->query('preceding-sibling::*[name()="' . $node->nodeName . '"]', $node)->length;
    $xpath = '/' . $node->nodeName . '[' . $position . ']' . $xpath;
    $node = $node->parentNode;
  } while (!$node instanceof DOMDocument);
  return $xpath;
}