}
}
- return $content->nodeValue;
+ return $this->subtree_or_text($content);
}
}
}
}
- return $content->nodeValue;
+ return $this->subtree_or_text($content);
}
}
}
}
+ function count_children($node) {
+ return $node->getElementsByTagName("*")->length;
+ }
+
+ function subtree_or_text($node) {
+ if ($this->count_children($node) == 0) {
+ return $node->nodeValue;
+ } else {
+ return $node->c14n();
+ }
+ }
}
?>
$contentB = $this->elem->getElementsByTagName("description")->item(0);
if ($contentA && !$contentB) {
- return $contentA->nodeValue;
+ return $this->subtree_or_text($contentA);
}
if ($contentB && !$contentA) {
- return $contentB->nodeValue;
+ return $this->subtree_or_text($contentB);
}
if ($contentA && $contentB) {
- return mb_strlen($contentA->nodeValue) > mb_strlen($contentB->nodeValue) ?
- $contentA->nodeValue : $contentB->nodeValue;
+ $resultA = $this->subtree_or_text($contentA);
+ $resultB = $this->subtree_or_text($contentB);
+
+ return mb_strlen($resultA) > mb_strlen($resultB) ? $resultA : $resultB;
}
}