33 foreach ($nodeList as $item) {
55 foreach ($tagNames as $tagName) {
56 $elements = $elem->getElementsByTagName($tagName);
57 foreach ($elements as $element) {
88 $xp =
new DOMXPath($doc);
89 $query = ($recursive === FALSE) ?
'*' :
'//*';
90 $query = $query.
'[@'.$attr.
' = "'.$value.
'"]';
91 $nodes = $xp->query($query, $element);
111 if ($node->hasChildNodes() === TRUE) {
112 foreach ($node->childNodes as $child) {
113 if ($child->nodeType === XML_ELEMENT_NODE) {
137 foreach ($node->childNodes as $child) {
138 if ($child->nodeType === XML_ELEMENT_NODE) {
160 foreach ($node->childNodes as $child) {
161 if ($child->nodeType === XML_ELEMENT_NODE) {
162 if ($pos === $position) {
186 foreach ($node->childNodes as $child) {
187 if ($child->nodeType === XML_ELEMENT_NODE) {
211 $nodeInfo[
'tagName'] = $element->tagName;
213 if ($element->hasAttributes() === TRUE) {
214 foreach ($element->attributes as $attribute) {
215 $nodeInfo[
'attrs'][$attribute->name] = $attribute->value;
219 if ($element->hasChildNodes() === TRUE) {
220 foreach ($element->childNodes as $childNode) {
221 if ($childNode->nodeType === XML_TEXT_NODE) {
222 $nodeInfo[
'value'] = trim($childNode->nodeValue);
223 }
else if ($childNode->tagName !== NULL) {
224 $nodeInfo[
'children'][] = self::traverseDOM($childNode);
247 public static function setAttributes(DomElement $element, array $attributes)
249 foreach ($attributes as $attrName => $attrValue) {
250 $element->setAttribute($attrName, $attrValue);