xmlAttrPtr attr;
zval tmp_zv;
int nodendx = 0;
+ int test;
sxe = php_sxe_fetch_object(object TSRMLS_CC);
if (sxe->iter.type == SXE_ITER_ATTRLIST) {
attribs = 1;
elements = 0;
- } else if (sxe->iter.type != SXE_ITER_CHILD && sxe->iter.type != SXE_ITER_ATTRLIST) {
node = php_sxe_get_first_node(sxe, node TSRMLS_CC);
+ attr = (xmlAttrPtr)node;
+ test = sxe->iter.name != NULL;
+ } else if (sxe->iter.type != SXE_ITER_CHILD) {
+ node = php_sxe_get_first_node(sxe, node TSRMLS_CC);
+ attr = node ? node->properties : NULL;
+ test = 0;
}
+
if (node) {
if (attribs) {
if (Z_TYPE_P(member) != IS_LONG || sxe->iter.type == SXE_ITER_ATTRLIST) {
- attr = node->properties;
if (Z_TYPE_P(member) == IS_LONG) {
while (attr && nodendx <= Z_LVAL_P(member)) {
- if (match_ns(sxe, (xmlNodePtr) attr, sxe->iter.nsprefix)) {
+ if ((!test || !xmlStrcmp(attr->name, sxe->iter.name)) && match_ns(sxe, (xmlNodePtr) attr, sxe->iter.nsprefix)) {
if (nodendx == Z_LVAL_P(member)) {
_node_as_zval(sxe, (xmlNodePtr) attr, return_value, SXE_ITER_NONE, NULL, sxe->iter.nsprefix TSRMLS_CC);
break;
}
} else {
while (attr) {
- if (!xmlStrcmp(attr->name, name) && match_ns(sxe, (xmlNodePtr) attr, sxe->iter.nsprefix)) {
+ if ((!test || !xmlStrcmp(attr->name, sxe->iter.name)) && !xmlStrcmp(attr->name, name) && match_ns(sxe, (xmlNodePtr) attr, sxe->iter.nsprefix)) {
_node_as_zval(sxe, (xmlNodePtr) attr, return_value, SXE_ITER_NONE, NULL, sxe->iter.nsprefix TSRMLS_CC);
break;
}
int counter = 0;
int is_attr = 0;
int nodendx = 0;
+ int test;
zval tmp_zv, trim_zv;
if (!member) {
GET_NODE(sxe, node);
- if (sxe->iter.type != SXE_ITER_ATTRLIST) {
+ if (sxe->iter.type == SXE_ITER_ATTRLIST) {
+ attribs = 1;
+ elements = 0;
node = php_sxe_get_first_node(sxe, node TSRMLS_CC);
+ attr = (xmlAttrPtr)node;
+ test = sxe->iter.name != NULL;
+ } else if (sxe->iter.type != SXE_ITER_CHILD) {
+ node = php_sxe_get_first_node(sxe, node TSRMLS_CC);
+ attr = node ? node->properties : NULL;
+ test = 0;
}
if (node) {
if (attribs) {
- attr = node->properties;
if (Z_TYPE_P(member) == IS_LONG) {
while (attr && nodendx <= Z_LVAL_P(member)) {
- if (match_ns(sxe, (xmlNodePtr) attr, sxe->iter.nsprefix)) {
+ if ((!test || !xmlStrcmp(attr->name, sxe->iter.name)) && match_ns(sxe, (xmlNodePtr) attr, sxe->iter.nsprefix)) {
if (nodendx == Z_LVAL_P(member)) {
is_attr = 1;
++counter;
}
} else {
while (attr) {
- if (!xmlStrcmp(attr->name, name) && match_ns(sxe, (xmlNodePtr) attr, sxe->iter.nsprefix)) {
+ if ((!test || !xmlStrcmp(attr->name, sxe->iter.name)) && !xmlStrcmp(attr->name, name) && match_ns(sxe, (xmlNodePtr) attr, sxe->iter.nsprefix)) {
is_attr = 1;
++counter;
break;
xmlNodePtr node;
xmlAttrPtr attr = NULL;
int exists = 0;
+ int test;
sxe = php_sxe_fetch_object(object TSRMLS_CC);
}
}
- if (sxe->iter.type != SXE_ITER_CHILD && sxe->iter.type != SXE_ITER_ATTRLIST) {
+ if (sxe->iter.type == SXE_ITER_ATTRLIST) {
+ attribs = 1;
+ elements = 0;
node = php_sxe_get_first_node(sxe, node TSRMLS_CC);
+ attr = (xmlAttrPtr)node;
+ test = sxe->iter.name != NULL;
+ } else if (sxe->iter.type != SXE_ITER_CHILD) {
+ node = php_sxe_get_first_node(sxe, node TSRMLS_CC);
+ attr = node ? node->properties : NULL;
+ test = 0;
}
if (node) {
if (attribs) {
- attr = node->properties;
while (attr) {
- if (!xmlStrcmp(attr->name, name) && match_ns(sxe, (xmlNodePtr) attr, sxe->iter.nsprefix)) {
+ if ((!test || !xmlStrcmp(attr->name, sxe->iter.name)) && !xmlStrcmp(attr->name, name) && match_ns(sxe, (xmlNodePtr) attr, sxe->iter.nsprefix)) {
exists = 1;
break;
}
xmlAttrPtr attr;
xmlAttrPtr anext;
zval tmp_zv;
+ int test;
if (Z_TYPE_P(member) != IS_STRING) {
tmp_zv = *member;
sxe = php_sxe_fetch_object(object TSRMLS_CC);
GET_NODE(sxe, node);
- node = php_sxe_get_first_node(sxe, node TSRMLS_CC);
+ if (sxe->iter.type == SXE_ITER_ATTRLIST) {
+ attribs = 1;
+ elements = 0;
+ node = php_sxe_get_first_node(sxe, node TSRMLS_CC);
+ attr = (xmlAttrPtr)node;
+ test = sxe->iter.name != NULL;
+ } else {
+ node = php_sxe_get_first_node(sxe, node TSRMLS_CC);
+ attr = node ? node->properties : NULL;
+ test = 0;
+ }
if (node) {
if (attribs) {
- attr = node->properties;
while (attr) {
anext = attr->next;
- if (!xmlStrcmp(attr->name, Z_STRVAL_P(member)) && match_ns(sxe, (xmlNodePtr) attr, sxe->iter.nsprefix)) {
+ if ((!test || !xmlStrcmp(attr->name, sxe->iter.name)) && !xmlStrcmp(attr->name, Z_STRVAL_P(member)) && match_ns(sxe, (xmlNodePtr) attr, sxe->iter.nsprefix)) {
xmlUnlinkNode((xmlNodePtr) attr);
php_libxml_node_free_resource((xmlNodePtr) attr TSRMLS_CC);
break;
xmlNodePtr node;
xmlAttrPtr attr;
int namelen;
+ int test;
sxe = php_sxe_fetch_object(object TSRMLS_CC);
}
attr = node ? (xmlAttrPtr)node->properties : NULL;
zattr = NULL;
+ test = sxe->iter.name && sxe->iter.type == SXE_ITER_ATTRLIST;
while (attr) {
- if (match_ns(sxe, (xmlNodePtr)attr, sxe->iter.nsprefix)) {
+ if ((!test || !xmlStrcmp(attr->name, sxe->iter.name)) && match_ns(sxe, (xmlNodePtr)attr, sxe->iter.nsprefix)) {
MAKE_STD_ZVAL(value);
ZVAL_STRING(value, xmlNodeListGetString((xmlDocPtr) sxe->document->ptr, attr->children, 1), 1);
namelen = xmlStrlen(attr->name) + 1;
}
sxe = php_sxe_fetch_object(getThis() TSRMLS_CC);
+
+ if (sxe->iter.type == SXE_ITER_ATTRLIST) {
+ return; /* attributes don't have attributes */
+ }
+
if (!sxe->xpath) {
sxe->xpath = xmlXPathNewContext((xmlDocPtr) sxe->document->ptr);
}
*/
if (nodeptr->type == XML_TEXT_NODE) {
_node_as_zval(sxe, nodeptr->parent, value, SXE_ITER_NONE, NULL, NULL TSRMLS_CC);
- } else {
+ } else if (nodeptr->type == XML_ATTRIBUTE_NODE) {
+ _node_as_zval(sxe, nodeptr->parent, value, SXE_ITER_ATTRLIST, (char*)nodeptr->name, NULL TSRMLS_CC);
+ } else {
_node_as_zval(sxe, nodeptr, value, SXE_ITER_NONE, NULL, NULL TSRMLS_CC);
}
}
sxe = php_sxe_fetch_object(getThis() TSRMLS_CC);
+
+ if (sxe->iter.type == SXE_ITER_ATTRLIST) {
+ return; /* attributes don't have attributes */
+ }
+
GET_NODE(sxe, node);
node = php_sxe_get_first_node(sxe, node TSRMLS_CC);
sxe = php_sxe_fetch_object(getThis() TSRMLS_CC);
GET_NODE(sxe, node);
+
+ if (sxe->iter.type == SXE_ITER_ATTRLIST) {
+ return; /* attributes don't have attributes */
+ }
+
node = php_sxe_get_first_node(sxe, node TSRMLS_CC);
_node_as_zval(sxe, node, return_value, SXE_ITER_ATTRLIST, NULL, nsprefix TSRMLS_CC);
}
} else {
if (node->type == XML_ATTRIBUTE_NODE) {
- if (match_ns(sxe, node, sxe->iter.nsprefix)) {
+ if (sxe->iter.type == SXE_ITER_ATTRLIST && sxe->iter.name) {
+ if (!xmlStrcmp(node->name, sxe->iter.name) && match_ns(sxe, node, prefix)) {
+ break;
+ }
+ } else if (match_ns(sxe, node, sxe->iter.nsprefix)) {
break;
}
}
}
} else {
if (node->type == XML_ATTRIBUTE_NODE) {
- if (match_ns(sxe, node, sxe->iter.nsprefix)) {
+ if (sxe->iter.type == SXE_ITER_ATTRLIST && sxe->iter.name) {
+ if (!xmlStrcmp(node->name, sxe->iter.name) && match_ns(sxe, node, prefix)) {
+ break;
+ }
+ } else if (match_ns(sxe, node, sxe->iter.nsprefix)) {
break;
}
}