本文整理汇总了C++中dom_object_get_node函数的典型用法代码示例。如果您正苦于以下问题:C++ dom_object_get_node函数的具体用法?C++ dom_object_get_node怎么用?C++ dom_object_get_node使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dom_object_get_node函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: dom_attr_owner_element_read
/* {{{ ownerElement DOMElement
readonly=yes
URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Attr-ownerElement
Since: DOM Level 2
*/
int dom_attr_owner_element_read(dom_object *obj, zval *retval)
{
xmlNodePtr nodep, nodeparent;
nodep = dom_object_get_node(obj);
if (nodep == NULL) {
php_dom_throw_error(INVALID_STATE_ERR, 0);
return FAILURE;
}
nodeparent = nodep->parent;
if (!nodeparent) {
ZVAL_NULL(retval);
return SUCCESS;
}
php_dom_create_object(nodeparent, retval, obj);
return SUCCESS;
}
开发者ID:ghfjdksl,项目名称:php-src,代码行数:26,代码来源:attr.c
示例2: dom_processinginstruction_data_read
/* {{{ data string
readonly=no
URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-837822393
Since:
*/
int dom_processinginstruction_data_read(dom_object *obj, zval *retval)
{
xmlNodePtr nodep;
xmlChar *content;
nodep = dom_object_get_node(obj);
if (nodep == NULL) {
php_dom_throw_error(INVALID_STATE_ERR, 0);
return FAILURE;
}
if ((content = xmlNodeGetContent(nodep)) != NULL) {
ZVAL_STRING(retval, (char *) content);
xmlFree(content);
} else {
ZVAL_EMPTY_STRING(retval);
}
return SUCCESS;
}
开发者ID:Jille,项目名称:php-src,代码行数:26,代码来源:processinginstruction.c
示例3: dom_node_text_content_read
/* {{{ textContent string
readonly=no
URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Node3-textContent
Since: DOM Level 3
*/
int dom_node_text_content_read(dom_object *obj, zval *retval)
{
xmlNode *nodep = dom_object_get_node(obj);
char *str = NULL;
if (nodep == NULL) {
php_dom_throw_error(INVALID_STATE_ERR, 0);
return FAILURE;
}
str = (char *) xmlNodeGetContent(nodep);
if (str != NULL) {
ZVAL_STRING(retval, str);
xmlFree(str);
} else {
ZVAL_EMPTY_STRING(retval);
}
return SUCCESS;
}
开发者ID:IMSoP,项目名称:php-src,代码行数:26,代码来源:node.c
示例4: dom_attr_value_write
int dom_attr_value_write(dom_object *obj, zval *newval)
{
zend_string *str;
xmlAttrPtr attrp = (xmlAttrPtr) dom_object_get_node(obj);
if (attrp == NULL) {
php_dom_throw_error(INVALID_STATE_ERR, 0);
return FAILURE;
}
if (attrp->children) {
node_list_unlink(attrp->children);
}
str = zval_get_string(newval);
xmlNodeSetContentLen((xmlNodePtr) attrp, (xmlChar *) ZSTR_VAL(str), ZSTR_LEN(str) + 1);
zend_string_release(str);
return SUCCESS;
}
开发者ID:ghfjdksl,项目名称:php-src,代码行数:21,代码来源:attr.c
示例5: PHP_METHOD
/* {{{ proto void DOMEntityReference::__construct(string name); */
PHP_METHOD(domentityreference, __construct)
{
zval *id;
xmlNode *node;
xmlNodePtr oldnode = NULL;
dom_object *intern;
char *name;
size_t name_len, name_valid;
zend_error_handling error_handling;
zend_replace_error_handling(EH_THROW, dom_domexception_class_entry, &error_handling);
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os", &id, dom_entityreference_class_entry, &name, &name_len) == FAILURE) {
zend_restore_error_handling(&error_handling);
return;
}
zend_restore_error_handling(&error_handling);
name_valid = xmlValidateName((xmlChar *) name, 0);
if (name_valid != 0) {
php_dom_throw_error(INVALID_CHARACTER_ERR, 1);
RETURN_FALSE;
}
node = xmlNewReference(NULL, (xmlChar *) name);
if (!node) {
php_dom_throw_error(INVALID_STATE_ERR, 1);
RETURN_FALSE;
}
intern = Z_DOMOBJ_P(id);
if (intern != NULL) {
oldnode = dom_object_get_node(intern);
if (oldnode != NULL) {
php_libxml_node_free_resource(oldnode );
}
php_libxml_increment_node_ptr((php_libxml_node_object *)intern, node, (void *)intern);
}
}
开发者ID:Jille,项目名称:php-src,代码行数:41,代码来源:entityreference.c
示例6: dom_characterdata_length_read
/* {{{ length long
readonly=yes
URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-7D61178C
Since:
*/
int dom_characterdata_length_read(dom_object *obj, zval *retval)
{
xmlNodePtr nodep = dom_object_get_node(obj);
xmlChar *content;
long length = 0;
if (nodep == NULL) {
php_dom_throw_error(INVALID_STATE_ERR, 0);
return FAILURE;
}
content = xmlNodeGetContent(nodep);
if (content) {
length = xmlUTF8Strlen(content);
xmlFree(content);
}
ZVAL_LONG(retval, length);
return SUCCESS;
}
开发者ID:0xhacking,项目名称:php-src,代码行数:27,代码来源:characterdata.c
示例7: dom_node_node_value_read
/* {{{ nodeValue string
readonly=no
URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-F68D080
Since:
*/
int dom_node_node_value_read(dom_object *obj, zval *retval)
{
xmlNode *nodep = dom_object_get_node(obj);
char *str = NULL;
if (nodep == NULL) {
php_dom_throw_error(INVALID_STATE_ERR, 0);
return FAILURE;
}
/* Access to Element node is implemented as a convience method */
switch (nodep->type) {
case XML_ATTRIBUTE_NODE:
case XML_TEXT_NODE:
case XML_ELEMENT_NODE:
case XML_COMMENT_NODE:
case XML_CDATA_SECTION_NODE:
case XML_PI_NODE:
str = (char *) xmlNodeGetContent(nodep);
break;
case XML_NAMESPACE_DECL:
str = (char *) xmlNodeGetContent(nodep->children);
break;
default:
str = NULL;
break;
}
if(str != NULL) {
ZVAL_STRING(retval, str);
xmlFree(str);
} else {
ZVAL_NULL(retval);
}
return SUCCESS;
}
开发者ID:IMSoP,项目名称:php-src,代码行数:43,代码来源:node.c
示例8: dom_node_last_child_read
/* {{{ lastChild DomNode
readonly=yes
URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-61AD09FB
Since:
*/
int dom_node_last_child_read(dom_object *obj, zval *retval)
{
xmlNode *nodep, *last = NULL;
nodep = dom_object_get_node(obj);
if (nodep == NULL) {
php_dom_throw_error(INVALID_STATE_ERR, 0);
return FAILURE;
}
if (dom_node_children_valid(nodep) == SUCCESS) {
last = nodep->last;
}
if (!last) {
ZVAL_NULL(retval);
return SUCCESS;
}
php_dom_create_object(last, retval, obj);
return SUCCESS;
}
开发者ID:IMSoP,项目名称:php-src,代码行数:28,代码来源:node.c
示例9: dom_node_owner_document_read
/* {{{ ownerDocument DomDocument
readonly=yes
URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-node-ownerDoc
Since:
*/
int dom_node_owner_document_read(dom_object *obj, zval *retval)
{
xmlNode *nodep = dom_object_get_node(obj);
xmlDocPtr docp;
if (nodep == NULL) {
php_dom_throw_error(INVALID_STATE_ERR, 0);
return FAILURE;
}
if (nodep->type == XML_DOCUMENT_NODE || nodep->type == XML_HTML_DOCUMENT_NODE) {
ZVAL_NULL(retval);
return SUCCESS;
}
docp = nodep->doc;
if (!docp) {
return FAILURE;
}
php_dom_create_object((xmlNodePtr) docp, retval, obj);
return SUCCESS;
}
开发者ID:IMSoP,项目名称:php-src,代码行数:28,代码来源:node.c
示例10: php_libxml_increment_node_ptr
php_libxml_increment_node_ptr((php_libxml_node_object *)intern, (xmlNodePtr)nodep, (void *)intern TSRMLS_CC);
}
}
/* }}} end DOMAttr::__construct */
/* {{{ name string
readonly=yes
URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-1112119403
Since:
*/
int dom_attr_name_read(dom_object *obj, zval **retval TSRMLS_DC)
{
xmlAttrPtr attrp;
attrp = (xmlAttrPtr) dom_object_get_node(obj);
if (attrp == NULL) {
php_dom_throw_error(INVALID_STATE_ERR, 0 TSRMLS_CC);
return FAILURE;
}
ALLOC_ZVAL(*retval);
ZVAL_STRING(*retval, (char *) (attrp->name), 1);
return SUCCESS;
}
/* }}} */
/* {{{ specified boolean
开发者ID:lennonchan,项目名称:TeamTalk,代码行数:31,代码来源:attr.c
示例11: PHP_METHOD
/* {{{ proto void DOMElement::__construct(string name, [string value], [string uri]); */
PHP_METHOD(domelement, __construct)
{
zval *id;
xmlNodePtr nodep = NULL, oldnode = NULL;
dom_object *intern;
char *name, *value = NULL, *uri = NULL;
char *localname = NULL, *prefix = NULL;
int errorcode = 0, uri_len = 0;
int name_len, value_len = 0, name_valid;
xmlNsPtr nsptr = NULL;
zend_error_handling error_handling;
zend_replace_error_handling(EH_THROW, dom_domexception_class_entry, &error_handling TSRMLS_CC);
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os|s!s", &id, dom_element_class_entry, &name, &name_len, &value, &value_len, &uri, &uri_len) == FAILURE) {
zend_restore_error_handling(&error_handling TSRMLS_CC);
return;
}
zend_restore_error_handling(&error_handling TSRMLS_CC);
name_valid = xmlValidateName((xmlChar *) name, 0);
if (name_valid != 0) {
php_dom_throw_error(INVALID_CHARACTER_ERR, 1 TSRMLS_CC);
RETURN_FALSE;
}
/* Namespace logic is separate and only when uri passed in to insure no BC breakage */
if (uri_len > 0) {
errorcode = dom_check_qname(name, &localname, &prefix, uri_len, name_len);
if (errorcode == 0) {
nodep = xmlNewNode (NULL, (xmlChar *)localname);
if (nodep != NULL && uri != NULL) {
nsptr = dom_get_ns(nodep, uri, &errorcode, prefix);
xmlSetNs(nodep, nsptr);
}
}
xmlFree(localname);
if (prefix != NULL) {
xmlFree(prefix);
}
if (errorcode != 0) {
if (nodep != NULL) {
xmlFreeNode(nodep);
}
php_dom_throw_error(errorcode, 1 TSRMLS_CC);
RETURN_FALSE;
}
} else {
/* If you don't pass a namespace uri, then you can't set a prefix */
localname = xmlSplitQName2((xmlChar *)name, (xmlChar **) &prefix);
if (prefix != NULL) {
xmlFree(localname);
xmlFree(prefix);
php_dom_throw_error(NAMESPACE_ERR, 1 TSRMLS_CC);
RETURN_FALSE;
}
nodep = xmlNewNode(NULL, (xmlChar *) name);
}
if (!nodep) {
php_dom_throw_error(INVALID_STATE_ERR, 1 TSRMLS_CC);
RETURN_FALSE;
}
if (value_len > 0) {
xmlNodeSetContentLen(nodep, (xmlChar *) value, value_len);
}
intern = (dom_object *)zend_object_store_get_object(id TSRMLS_CC);
if (intern != NULL) {
oldnode = dom_object_get_node(intern);
if (oldnode != NULL) {
php_libxml_node_free_resource(oldnode TSRMLS_CC);
}
php_libxml_increment_node_ptr((php_libxml_node_object *)intern, nodep, (void *)intern TSRMLS_CC);
}
}
开发者ID:31H0B1eV,项目名称:php-src,代码行数:78,代码来源:element.c
示例12: dom_element_tag_name_read
}
}
/* }}} end DOMElement::__construct */
/* {{{ tagName string
readonly=yes
URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-104682815
Since:
*/
int dom_element_tag_name_read(dom_object *obj, zval **retval TSRMLS_DC)
{
xmlNodePtr nodep;
xmlNsPtr ns;
xmlChar *qname;
nodep = dom_object_get_node(obj);
if (nodep == NULL) {
php_dom_throw_error(INVALID_STATE_ERR, 0 TSRMLS_CC);
return FAILURE;
}
ALLOC_ZVAL(*retval);
ns = nodep->ns;
if (ns != NULL && ns->prefix) {
qname = xmlStrdup(ns->prefix);
qname = xmlStrcat(qname, (xmlChar *)":");
qname = xmlStrcat(qname, nodep->name);
ZVAL_STRING(*retval, (char *)qname, 1);
xmlFree(qname);
} else {
开发者ID:31H0B1eV,项目名称:php-src,代码行数:31,代码来源:element.c
示例13: dom_entity_public_id_read
*/
const zend_function_entry php_dom_entity_class_functions[] = {
PHP_FE_END
};
/* {{{ publicId string
readonly=yes
URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#ID-D7303025
Since:
*/
int dom_entity_public_id_read(dom_object *obj, zval **retval TSRMLS_DC)
{
xmlEntity *nodep;
nodep = (xmlEntity *) dom_object_get_node(obj);
if (nodep == NULL) {
php_dom_throw_error(INVALID_STATE_ERR, 0 TSRMLS_CC);
return FAILURE;
}
ALLOC_ZVAL(*retval);
if (nodep->etype != XML_EXTERNAL_GENERAL_UNPARSED_ENTITY) {
ZVAL_NULL(*retval);
} else {
ZVAL_STRING(*retval, (char *) (nodep->ExternalID), 1);
}
return SUCCESS;
}
开发者ID:do-aki,项目名称:petipeti,代码行数:31,代码来源:entity.c
示例14: xsl_ext_function_php
//.........这里部分代码省略.........
node->ns = curns;
} else {
node = xmlDocCopyNodeList(domintern->document->ptr, node);
}
php_dom_create_object(node, &child, domintern);
add_next_index_zval(&args[i], &child);
}
}
}
break;
default:
str = (char *) xmlXPathCastToString(obj);
ZVAL_STRING(&args[i], str);
xmlFree(str);
}
xmlXPathFreeObject(obj);
}
fci.size = sizeof(fci);
fci.function_table = EG(function_table);
if (fci.param_count > 0) {
fci.params = args;
} else {
fci.params = NULL;
}
obj = valuePop(ctxt);
if (obj->stringval == NULL) {
php_error_docref(NULL, E_WARNING, "Handler name must be a string");
xmlXPathFreeObject(obj);
valuePush(ctxt, xmlXPathNewString((const xmlChar *) ""));
if (fci.param_count > 0) {
for (i = 0; i < nargs - 1; i++) {
zval_ptr_dtor(&args[i]);
}
efree(args);
}
return;
}
ZVAL_STRING(&handler, (char *) obj->stringval);
xmlXPathFreeObject(obj);
ZVAL_COPY_VALUE(&fci.function_name, &handler);
fci.symbol_table = NULL;
fci.object = NULL;
fci.retval = &retval;
fci.no_separation = 0;
/*fci.function_handler_cache = &function_ptr;*/
if (!zend_make_callable(&handler, &callable)) {
php_error_docref(NULL, E_WARNING, "Unable to call handler %s()", ZSTR_VAL(callable));
valuePush(ctxt, xmlXPathNewString((const xmlChar *) ""));
} else if ( intern->registerPhpFunctions == 2 && zend_hash_exists(intern->registered_phpfunctions, callable) == 0) {
php_error_docref(NULL, E_WARNING, "Not allowed to call handler '%s()'", ZSTR_VAL(callable));
/* Push an empty string, so that we at least have an xslt result... */
valuePush(ctxt, xmlXPathNewString((const xmlChar *) ""));
} else {
result = zend_call_function(&fci, NULL);
if (result == FAILURE) {
if (Z_TYPE(handler) == IS_STRING) {
php_error_docref(NULL, E_WARNING, "Unable to call handler %s()", Z_STRVAL(handler));
valuePush(ctxt, xmlXPathNewString((const xmlChar *) ""));
}
/* retval is == NULL, when an exception occurred, don't report anything, because PHP itself will handle that */
} else if (Z_ISUNDEF(retval)) {
} else {
if (Z_TYPE(retval) == IS_OBJECT && instanceof_function(Z_OBJCE(retval), dom_node_class_entry)) {
xmlNode *nodep;
dom_object *obj;
if (intern->node_list == NULL) {
ALLOC_HASHTABLE(intern->node_list);
zend_hash_init(intern->node_list, 0, NULL, ZVAL_PTR_DTOR, 0);
}
Z_ADDREF(retval);
zend_hash_next_index_insert(intern->node_list, &retval);
obj = Z_DOMOBJ_P(&retval);
nodep = dom_object_get_node(obj);
valuePush(ctxt, xmlXPathNewNodeSet(nodep));
} else if (Z_TYPE(retval) == IS_TRUE || Z_TYPE(retval) == IS_FALSE) {
valuePush(ctxt, xmlXPathNewBoolean(Z_LVAL(retval)));
} else if (Z_TYPE(retval) == IS_OBJECT) {
php_error_docref(NULL, E_WARNING, "A PHP Object cannot be converted to a XPath-string");
valuePush(ctxt, xmlXPathNewString((const xmlChar *) ""));
} else {
convert_to_string_ex(&retval);
valuePush(ctxt, xmlXPathNewString((xmlChar *) Z_STRVAL(retval)));
}
zval_ptr_dtor(&retval);
}
}
zend_string_release(callable);
zval_ptr_dtor(&handler);
if (fci.param_count > 0) {
for (i = 0; i < nargs - 1; i++) {
zval_ptr_dtor(&args[i]);
}
efree(args);
}
}
开发者ID:guggemand,项目名称:php-src,代码行数:101,代码来源:xsltprocessor.c
示例15: dom_xpath_ext_function_php
//.........这里部分代码省略.........
for (j = 0; j < obj->nodesetval->nodeNr; j++) {
xmlNodePtr node = obj->nodesetval->nodeTab[j];
zval child;
/* not sure, if we need this... it's copied from xpath.c */
if (node->type == XML_NAMESPACE_DECL) {
xmlNsPtr curns;
xmlNodePtr nsparent;
nsparent = node->_private;
curns = xmlNewNs(NULL, node->name, NULL);
if (node->children) {
curns->prefix = xmlStrdup((xmlChar *) node->children);
}
if (node->children) {
node = xmlNewDocNode(node->doc, NULL, (xmlChar *) node->children, node->name);
} else {
node = xmlNewDocNode(node->doc, NULL, (xmlChar *) "xmlns", node->name);
}
node->type = XML_NAMESPACE_DECL;
node->parent = nsparent;
node->ns = curns;
}
php_dom_create_object(node, &child, &intern->dom);
add_next_index_zval(&fci.params[i], &child);
}
}
}
break;
default:
ZVAL_STRING(&fci.params[i], (char *)xmlXPathCastToString(obj));
}
xmlXPathFreeObject(obj);
}
fci.size = sizeof(fci);
fci.function_table = EG(function_table);
obj = valuePop(ctxt);
if (obj->stringval == NULL) {
php_error_docref(NULL, E_WARNING, "Handler name must be a string");
xmlXPathFreeObject(obj);
if (fci.param_count > 0) {
for (i = 0; i < nargs - 1; i++) {
zval_ptr_dtor(&fci.params[i]);
}
efree(fci.params);
}
return;
}
ZVAL_STRING(&fci.function_name, (char *) obj->stringval);
xmlXPathFreeObject(obj);
fci.symbol_table = NULL;
fci.object = NULL;
fci.retval = &retval;
fci.no_separation = 0;
if (!zend_make_callable(&fci.function_name, &callable)) {
php_error_docref(NULL, E_WARNING, "Unable to call handler %s()", callable->val);
} else if (intern->registerPhpFunctions == 2 && zend_hash_exists(intern->registered_phpfunctions, callable) == 0) {
php_error_docref(NULL, E_WARNING, "Not allowed to call handler '%s()'.", callable->val);
/* Push an empty string, so that we at least have an xslt result... */
valuePush(ctxt, xmlXPathNewString((xmlChar *)""));
} else {
result = zend_call_function(&fci, NULL);
if (result == SUCCESS && Z_TYPE(retval) != IS_UNDEF) {
if (Z_TYPE(retval) == IS_OBJECT && instanceof_function(Z_OBJCE(retval), dom_node_class_entry)) {
xmlNode *nodep;
dom_object *obj;
if (intern->node_list == NULL) {
ALLOC_HASHTABLE(intern->node_list);
zend_hash_init(intern->node_list, 0, NULL, ZVAL_PTR_DTOR, 0);
}
GC_REFCOUNT(&retval)++;
zend_hash_next_index_insert(intern->node_list, &retval);
obj = Z_DOMOBJ_P(&retval);
nodep = dom_object_get_node(obj);
valuePush(ctxt, xmlXPathNewNodeSet(nodep));
} else if (Z_TYPE(retval) == IS_FALSE || Z_TYPE(retval) == IS_TRUE) {
valuePush(ctxt, xmlXPathNewBoolean(Z_TYPE(retval) == IS_TRUE));
} else if (Z_TYPE(retval) == IS_OBJECT) {
php_error_docref(NULL, E_WARNING, "A PHP Object cannot be converted to a XPath-string");
valuePush(ctxt, xmlXPathNewString((xmlChar *)""));
} else {
zend_string *str = zval_get_string(&retval);
valuePush(ctxt, xmlXPathNewString((xmlChar *) str->val));
zend_string_release(str);
}
zval_ptr_dtor(&retval);
}
}
zend_string_release(callable);
zval_dtor(&fci.function_name);
if (fci.param_count > 0) {
for (i = 0; i < nargs - 1; i++) {
zval_ptr_dtor(&fci.params[i]);
}
efree(fci.params);
}
}
开发者ID:0xhacking,项目名称:php-src,代码行数:101,代码来源:xpath.c
示例16: php_dom_iterator_move_forward
static void php_dom_iterator_move_forward(zend_object_iterator *iter) /* {{{ */
{
zval *object;
xmlNodePtr curnode = NULL, basenode;
dom_object *intern;
dom_object *nnmap;
dom_nnodemap_object *objmap;
int previndex=0;
HashTable *nodeht;
zval *entry;
zend_bool do_curobj_undef = 1;
php_dom_iterator *iterator = (php_dom_iterator *)iter;
object = &iterator->intern.data;
nnmap = Z_DOMOBJ_P(object);
objmap = (dom_nnodemap_object *)nnmap->ptr;
intern = Z_DOMOBJ_P(&iterator->curobj);
if (intern != NULL && intern->ptr != NULL) {
if (objmap->nodetype != XML_ENTITY_NODE &&
objmap->nodetype != XML_NOTATION_NODE) {
if (objmap->nodetype == DOM_NODESET) {
nodeht = HASH_OF(&objmap->baseobj_zv);
zend_hash_move_forward_ex(nodeht, &iterator->pos);
if ((entry = zend_hash_get_current_data_ex(nodeht, &iterator->pos))) {
zval_ptr_dtor(&iterator->curobj);
ZVAL_UNDEF(&iterator->curobj);
ZVAL_COPY(&iterator->curobj, entry);
do_curobj_undef = 0;
}
} else {
curnode = (xmlNodePtr)((php_libxml_node_ptr *)intern->ptr)->node;
if (objmap->nodetype == XML_ATTRIBUTE_NODE ||
objmap->nodetype == XML_ELEMENT_NODE) {
curnode = curnode->next;
} else {
/* Nav the tree evey time as this is LIVE */
basenode = dom_object_get_node(objmap->baseobj);
if (basenode && (basenode->type == XML_DOCUMENT_NODE ||
basenode->type == XML_HTML_DOCUMENT_NODE)) {
basenode = xmlDocGetRootElement((xmlDoc *) basenode);
} else if (basenode) {
basenode = basenode->children;
} else {
goto err;
}
curnode = dom_get_elements_by_tag_name_ns_raw(
basenode, (char *) objmap->ns, (char *) objmap->local, &previndex, iter->index);
}
}
} else {
if (objmap->nodetype == XML_ENTITY_NODE) {
curnode = php_dom_libxml_hash_iter(objmap->ht, iter->index);
} else {
curnode = php_dom_libxml_notation_iter(objmap->ht, iter->index);
}
}
}
err:
if (do_curobj_undef) {
zval_ptr_dtor(&iterator->curobj);
ZVAL_UNDEF(&iterator->curobj);
}
if (curnode) {
php_dom_create_object(curnode, &iterator->curobj, objmap->baseobj);
}
}
开发者ID:daniel-higa,项目名称:php-src,代码行数:69,代码来源:dom_iterators.c
示例17: dom_node_prefix_write
int dom_node_prefix_write(dom_object *obj, zval *newval)
{
zend_string *str;
xmlNode *nodep, *nsnode = NULL;
xmlNsPtr ns = NULL, curns;
char *strURI;
char *prefix;
nodep = dom_object_get_node(obj);
if (nodep == NULL) {
php_dom_throw_error(INVALID_STATE_ERR, 0);
return FAILURE;
}
switch (nodep->type) {
case XML_ELEMENT_NODE:
nsnode = nodep;
case XML_ATTRIBUTE_NODE:
if (nsnode == NULL) {
nsnode = nodep->parent;
if (nsnode == NULL) {
nsnode = xmlDocGetRootElement(nodep->doc);
}
}
str = zval_get_string(newval);
prefix = ZSTR_VAL(str);
if (nsnode && nodep->ns != NULL && !xmlStrEqual(nodep->ns->prefix, (xmlChar *)prefix)) {
strURI = (char *) nodep->ns->href;
if (strURI == NULL ||
(!strcmp(prefix, "xml") && strcmp(strURI, (char *) XML_XML_NAMESPACE)) ||
(nodep->type == XML_ATTRIBUTE_NODE && !strcmp(prefix, "xmlns") &&
strcmp(strURI, (char *) DOM_XMLNS_NAMESPACE)) ||
(nodep->type == XML_ATTRIBUTE_NODE && !strcmp((char *) nodep->name, "xmlns"))) {
ns = NULL;
} else {
curns = nsnode->nsDef;
while (curns != NULL) {
if (xmlStrEqual((xmlChar *)prefix, curns->prefix) && xmlStrEqual(nodep->ns->href, curns->href)) {
ns = curns;
break;
}
curns = curns->next;
}
if (ns == NULL) {
ns = xmlNewNs(nsnode, nodep->ns->href, (xmlChar *)prefix);
}
}
if (ns == NULL) {
zend_string_release_ex(str, 0);
php_dom_throw_error(NAMESPACE_ERR, dom_get_strict_error(obj->document));
return FAILURE;
}
xmlSetNs(nodep, ns);
}
zend_string_release_ex(str, 0);
break;
default:
break;
}
return SUCCESS;
}
开发者ID:IMSoP,项目名称:php-src,代码行数:65,代码来源:node.c
示例18: zend_error
zend_object_iterator *php_dom_get_iterator(zend_class_entry *ce, zval *object, int by_ref) /* {{{ */
{
dom_object *intern;
dom_nnodemap_object *objmap;
xmlNodePtr nodep, curnode=NULL;
int curindex = 0;
HashTable *nodeht;
zval *entry;
php_dom_iterator *iterator;
if (by_ref) {
zend_error(E_ERROR, "An iterator cannot be used with foreach by reference");
}
iterator = emalloc(sizeof(php_dom_iterator));
zend_iterator_init(&iterator->intern);
ZVAL_COPY(&iterator->intern.data, object);
iterator->intern.funcs = &php_dom_iterator_funcs;
ZVAL_UNDEF(&iterator->curobj);
intern = Z_DOMOBJ_P(object);
objmap = (dom_nnodemap_object *)intern->ptr;
if (objmap != NULL) {
if (objmap->nodetype != XML_ENTITY_NODE &&
objmap->nodetype != XML_NOTATION_NODE) {
if (objmap->nodetype == DOM_NODESET) {
nodeht = HASH_OF(&objmap->baseobj_zv);
zend_hash_internal_pointer_reset_ex(nodeht, &iterator->pos);
if ((entry = zend_hash_get_current_data_ex(nodeht, &iterator->pos))) {
ZVAL_COPY(&iterator->curobj, entry);
}
} else {
nodep = (xmlNode *)dom_object_get_node(objmap->baseobj);
if (!nodep) {
goto err;
}
if (objmap->nodetype == XML_ATTRIBUTE_NODE || objmap->nodetype == XML_ELEMENT_NODE) {
if (objmap->nodetype == XML_ATTRIBUTE_NODE) {
curnode = (xmlNodePtr) nodep->properties;
} else {
curnode = (xmlNodePtr) nodep->children;
}
} else {
if (nodep->type == XML_DOCUMENT_NODE || nodep->type == XML_HTML_DOCUMENT_NODE) {
nodep = xmlDocGetRootElement((xmlDoc *) nodep);
} else {
nodep = nodep->children;
}
curnode = dom_get_elements_by_tag_name_ns_raw(
nodep, (char *) objmap->ns, (char *) objmap->local, &curindex, 0);
}
}
} else {
if (objmap->nodetype == XML_ENTITY_NODE) {
curnode = php_dom_libxml_hash_iter(objmap->ht, 0);
} else {
curnode = php_dom_libxml_notation_iter(objmap->ht, 0);
}
}
}
err:
if (curnode) {
php_dom_create_object(curnode, &iterator->curobj, objmap->baseobj);
}
return &iterator->intern;
}
开发者ID:daniel-higa,项目名称:php-src,代码行数:68,代码来源:dom_iterators.c
示例19: dom_node_node_name_read
/* {{{ nodeName string
readonly=yes
URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-F68D095
Since:
*/
int dom_node_node_name_read(dom_object *obj, zval *retval)
{
xmlNode *nodep;
xmlNsPtr ns;
char *str = NULL;
xmlChar *qname = NULL;
nodep = dom_object_get_node(obj);
if (nodep == NULL) {
php_dom_throw_error(INVALID_STATE_ERR, 0);
return FAILURE;
}
switch (nodep->type) {
case XML_ATTRIBUTE_NODE:
case XML_ELEMENT_NODE:
ns = nodep->ns;
if (ns != NULL && ns->prefix) {
qname = xmlStrdup(ns->prefix);
qname = xmlStrcat(qname, (xmlChar *) ":");
qname = xmlStrcat(qname, nodep->name);
str = (char *) qname;
} else {
str = (char *) nodep->name;
}
break;
case XML_NAMESPACE_DECL:
ns = nodep->ns;
if (ns != NULL && ns->prefix) {
qname = xmlStrdup((xmlChar *) "xmlns");
qname = xmlStrcat(qname, (xmlChar *) ":");
qname = xmlStrcat(qname, nodep->name);
str = (char *) qname;
} else {
str = (char *) nodep->name;
}
break;
case XML_DOCUMENT_TYPE_NODE:
case XML_DTD_NODE:
case XML_PI_NODE:
case XML_ENTITY_DECL:
case XML_ENTITY_REF_NODE:
case XML_NOTATION_NODE:
str = (char *) nodep->name;
break;
case XML_CDATA_SECTION_NODE:
str = "#cdata-section";
break;
case XML_COMMENT_NODE:
str = "#comment";
break;
case XML_HTML_DOCUMENT_NODE:
case XML_DOCUMENT_NODE:
str = "#document";
break;
case XML_DOCUMENT_FRAG_NODE:
str = "#document-fragment";
break;
case XML_TEXT_NODE:
str = "#text";
break;
default:
php_error_docref(NULL, E_WARNING, "Invalid Node Type");
}
if (str != NULL) {
ZVAL_STRING(retval, str);
} else {
ZVAL_EMPTY_STRING(retval);
}
if (qname != NULL) {
xmlFree(qname);
}
return SUCCESS;
}
开发者ID:IMSoP,项目名称:php-src,代码行数:84,代码来源:node.c
示例20: PHP_FALIAS
PHP_FALIAS(substringData, dom_characterdata_substring_data, arginfo_dom_characterdata_substring_data)
PHP_FALIAS(appendData, dom_characterdata_append_data, arginfo_dom_characterdata_append_data)
PHP_FALIAS(insertData, dom_characterdata_insert_data, arginfo_dom_characterdata_insert_data)
PHP_FALIAS(deleteData, dom_characterdata_delete_data, arginfo_dom_characterdata_delete_data)
PHP_FALIAS(replaceData, dom_characterdata_replace_data, arginfo_dom_characterdata_replace_data)
PHP_FE_END
};
/* {{{ data string
readonly=no
URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-72AB8359
Since:
*/
int dom_characterdata_data_read(dom_object *obj, zval *retval TSRMLS_DC)
{
xmlNodePtr nodep = dom_object_get_node(obj);
xmlChar *content;
if (nodep == NULL) {
php_dom_throw_error(INVALID_STATE_ERR, 0 TSRMLS_CC);
return FAILURE;
}
if ((content = xmlNodeGetContent(nodep)) != NULL) {
ZVAL_STRING(retval, (char *) content);
xmlFree(content);
} else {
ZVAL_EMPTY_STRING(retval);
}
return SUCCESS;
开发者ID:0x1111,项目名称:php-src,代码行数:31,代码来源:characterdata.c
注:本文中的dom_object_get_node函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论