Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:7016 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 69901 invoked by uid 1010); 12 Jan 2004 22:24:10 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 69877 invoked by uid 1007); 12 Jan 2004 22:24:10 -0000 Message-ID: <20040112222409.69858.qmail@pb1.pair.com> To: internals@lists.php.net Reply-To: alex_mailbox53@yahoo.com Date: Tue, 13 Jan 2004 00:30:41 +0200 References: <20040112152620.20216.qmail@pb1.pair.com> <20040112192340.GB13302@bumblebury.com> Lines: 88 User-Agent: KNode/0.7.2 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Posted-By: 193.111.127.34 Subject: Re: [PHP-DEV] How to add new functions to SimpleXML extention From: alex_mailbox53@yahoo.com (Alexander) Hi, Hope, I understand your point. It looks like having two DOMs is not in your plans :-) getParent is really equal to xsearch('..'). But what about name? Is it possible to get the name of the current simplexml_element using xsearch? I also wonder if I created "right" functions because I plan to create a tutor article "How to extend PHP" with these functions as examples. Are they correct from this point of view? Regards, Alexander Netkachev Sterling Hughes wrote: > Funny, i writing a response to adam's message while this got to the > mailing list. Take a look at my response to adam, as it covers this > patch as well. > > -Sterling > >> Hi! >> >> I'm just playing with simplexml and wonder if two new functions of the >> simplexml_element object would be usefull: getName() and getParent(). I'm >> interesting in adding them to the extention, if possible. What should I >> do for this? (I also think that it may be in FAQ, but I did not find that >> info with my search skills). >> Basically, this is my first experiment with PHP Extensions. I may be >> wrong with my code, but tests pass is ok >> >> ----------------------- >> Thank you for time, >> Alexander Netkachev >> http://devlink.narod.ru/ >> >> Code for getName function: >> /* {{{ getName() >> */ >> SXE_METHOD(getName) >> { >> char *name; >> xmlNodePtr node; // current node >> php_sxe_object *sxe = php_sxe_fetch_object(getThis() TSRMLS_CC); >> GET_NODE(sxe, node); >> if (node && (name = (char *)(node->name))) { >> RETURN_STRING(name, 1); >> } >> RETURN_EMPTY_STRING(); >> } >> /* }}} */ >> >> /* {{{ getParent() >> */ >> SXE_METHOD(getParent) >> { >> xmlNodePtr node; // current node >> xmlNodePtr pNode; // node->parent >> php_sxe_object *sxe = php_sxe_fetch_object(getThis() TSRMLS_CC); >> GET_NODE(sxe, node); >> if (node && (pNode = node->parent)) { >> _node_as_zval(sxe, pNode, return_value TSRMLS_CC); >> return; >> } >> RETURN_NULL(); >> } >> /* }}} */ >> >> File: ext/simplexml/tests/019.phpt >> --TEST-- >> SimpleXML: Test getParent() and getName() functions >> --SKIPIF-- >> >> --FILE-- >> > $doc = simplexml_load_string(''); >> var_dump(trim($doc->body->getParent()->getName())); >> echo '--done--'; >> ?> >> --EXPECT-- >> string(4) "html" >> --done-- >> >> -- >> PHP Internals - PHP Runtime Development Mailing List >> To unsubscribe, visit: http://www.php.net/unsub.php >>