本文整理汇总了C++中dom_object_get_node函数的典型用法代码示例。如果您正苦于以下问题:C++ dom_object_get_node函数的具体用法?C++ dom_object_get_node怎么用?C++ dom_object_get_node使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dom_object_get_node函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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
示例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);
}
}
示例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 {
示例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;
}
示例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);
}
}
示例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);
}
}