add_next_index_zval(return_value, __v); \
}
+#define GET_NODE(__s, __n) (__n) = (__s)->node ? (__s)->node : xmlDocGetRootElement((__s)->document)
+
/* {{{ sxe_property_read()
*/
static zval *
return return_value;
}
- if (sxe->node) {
- node = sxe->node->xmlChildrenNode;
- } else {
- node = sxe->node = xmlDocGetRootElement(sxe->document)->xmlChildrenNode;
- }
+ GET_NODE(sxe, node);
- attr = sxe->node->properties;
+ attr = node->properties;
while (attr) {
if (!xmlStrcmp(attr->name, name)) {
APPEND_PREV_ELEMENT(counter, value);
attr = attr->next;
}
+ node = node->xmlChildrenNode;
+ if (!sxe->node) {
+ sxe->node = node;
+ }
+
while (node) {
if (!xmlStrcmp(node->name, name)) {
APPEND_PREV_ELEMENT(counter, value);
case IS_NULL:
convert_to_string(value);
case IS_STRING:
- node->children->content = xmlStrndup(Z_STRVAL_P(value), Z_STRLEN_P(value));
+ node->xmlChildrenNode->content = xmlStrndup(Z_STRVAL_P(value), Z_STRLEN_P(value));
break;
default:
php_error(E_WARNING, "It is not yet possible to assign complex types to attributes");
}
/* }}} */
+
/* {{{ sxe_property_write()
*/
static void
name = Z_STRVAL_P(member);
sxe = php_sxe_fetch_object(object TSRMLS_CC);
- node = sxe->node ? sxe->node->xmlChildrenNode : xmlDocGetRootElement(sxe->document)->xmlChildrenNode;
+ GET_NODE(sxe, node);
+ node = node->xmlChildrenNode;
while (node) {
if (!xmlStrcmp(node->name, name)) {
static int
sxe_property_exists(zval *object, zval *member, int check_empty TSRMLS_DC)
{
+ php_sxe_object *sxe;
+ char *name;
+ xmlNodePtr node;
+ xmlAttrPtr attr;
+ sxe = php_sxe_fetch_object(object TSRMLS_CC);
+ name = Z_STRVAL_P(member);
+
+ GET_NODE(sxe, node);
+
+ attr = node->properties;
+ while (attr) {
+ if (!xmlStrcmp(attr->name, name)) {
+ return 1;
+ }
+
+ attr = attr->next;
+ }
+
+ node = node->xmlChildrenNode;
+ while (node) {
+ if (!xmlStrcmp(node->name, name)) {
+ return 1;
+ }
+
+ node = node->next;
+ }
+
+ return 0;
}
/* }}} */