public function mimemail_compress::calculateXPath in Mime Mail 7
Same name and namespace in other branches
- 6 modules/mimemail_compress/mimemail_compress.inc \mimemail_compress::calculateXPath()
Get the full path to a DOM node.
Parameters
DOMNode $node: The node to analyze.
Return value
string The full xpath to a DOM node.
See also
http://stackoverflow.com/questions/2643533/php-getting-xpath-of-a-domnode
1 call to mimemail_compress::calculateXPath()
- mimemail_compress::compress in modules/
mimemail_compress/ mimemail_compress.inc
File
- modules/
mimemail_compress/ mimemail_compress.inc, line 321 - Converts CSS styles into inline style attributes.
Class
- mimemail_compress
- Compresses HTML and CSS into combined message.
Code
public 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;
}