Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #14218
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Re: Extracting values from xml file using php/xpath/namespace/simplexml/ |
| Date | 2014-09-07 09:54 -0400 |
| Organization | A noiseless patient Spider |
| Message-ID | <luho38$ni7$1@dont-email.me> (permalink) |
| References | (9 earlier) <2974602.zgg0cvazeg@PointedEars.de> <lub0uq$8cj$1@dont-email.me> <lub5tu$k7f$3@solani.org> <lub8dn$glf$2@dont-email.me> <1803376.fJyM96K0rL@PointedEars.de> |
On 9/7/2014 5:57 AM, Thomas 'PointedEars' Lahn wrote: > Denis McMahon wrote: > >> On Fri, 05 Sep 2014 04:08:09 +0200, Christoph M. Becker wrote: >>> Jerry Stuckle wrote: >>>> On 9/4/2014 5:21 PM, Thomas 'Pointed Head' Lahn wrote: >>>>> Jerry Stuckle wrote: >>>> His code will detect the change in the markup. Yours will not, because >>>> you are not using the full XPath. And once again - yours can fail if >>>> the XML happens to have multiple (but different) XPaths with the same >>>> identifiers. The Ops will not. >>> >>> "Mutitple (but different) XPaths"? Do you mean multiple (but different) >>> XPath expressions? >> >> No >> >> Jerry is trying to point out to tpel-troll that if you use a partial xpath >> instead of a fully qualified xpath to match data in an xml document, >> there is a risk that if the same partial xpath matches one or more >> unwanted elements as well as the wanted element(s), the unwanted element >> (s) will end up as part of the selection. > > If he would have, this would be showing that he does not understand XPath. > As you assume he did, you clearly do not understand XPath. > > An XPath query always matches all elements that match that path. In a XML > document > > <foo> > <bar id="baz" /> > <bar id="bla" /> > </foo> > > the path '/foo/bar' matches <bar id="baz" /> *and* <bar id="bla" />. > > Therefore, the return value of SimpleXMLElement::xpath() is *always* an > array, unless the query is syntactically in error, in which case the return > value is FALSE. > > As for “unwanted elements”, it is a fallacy to assume that if the structure > of the XML document changes, a more general query *must* return unwanted > elements. For example, if the structure changes to > > <foo> > <bars> > <bar id="baz" /> > <bar id="bla" /> > </bars> > </foo> > > (which makes sense structurally) the result for the more general XPath query > './/bar' will still contain only wanted elements, namely still only <bar > id="baz" /> and <bar id="bla" />. It could be further refined by using > /bars[1] as *context node* (using '.' in the path), referring only to nodes > *below* that node in the hierarchy of the data structure. This is what I > referred to with flexibility. > > IOW: Using the full XPath path is _not_ always the best approach. > Once again you're as full of crap as your code is full of holes. But I should know better than to try to teach the troll. It's like trying to teach a pig to sing. -- ================== Remove the "x" from my email address Jerry Stuckle jstucklex@attglobal.net ==================
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Extracting values from xml file using php/xpath/namespace/simplexml/ ofuuzo@gmail.com - 2014-08-13 04:02 -0700
Re: Extracting values from xml file using php/xpath/namespace/simplexml/ Jerry Stuckle <jstucklex@attglobal.net> - 2014-08-13 09:25 -0400
Re: Extracting values from xml file using php/xpath/namespace/simplexml/ ofuuzo@gmail.com - 2014-08-14 03:29 -0700
Re: Extracting values from xml file using php/xpath/namespace/simplexml/ Jerry Stuckle <jstucklex@attglobal.net> - 2014-08-14 10:06 -0400
Re: Extracting values from xml file using php/xpath/namespace/simplexml/ Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-08-17 19:43 +0200
Re: Extracting values from xml file using php/xpath/namespace/simplexml/ Jerry Stuckle <jstucklex@attglobal.net> - 2014-08-17 15:21 -0400
Re: Extracting values from xml file using php/xpath/namespace/simplexml/ Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-08-17 23:41 +0200
Re: Extracting values from xml file using php/xpath/namespace/simplexml/ Jerry Stuckle <jstucklex@attglobal.net> - 2014-08-17 18:57 -0400
Re: Extracting values from xml file using php/xpath/namespace/simplexml/ Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-09-03 23:10 +0200
Re: Extracting values from xml file using php/xpath/namespace/simplexml/ Jerry Stuckle <jstucklex@attglobal.net> - 2014-09-03 20:11 -0400
Re: Extracting values from xml file using php/xpath/namespace/simplexml/ "Christoph M. Becker" <cmbecker69@arcor.de> - 2014-09-04 02:42 +0200
Re: Extracting values from xml file using php/xpath/namespace/simplexml/ Jerry Stuckle <jstucklex@attglobal.net> - 2014-09-03 21:57 -0400
Re: Extracting values from xml file using php/xpath/namespace/simplexml/ Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-09-04 23:21 +0200
Re: Extracting values from xml file using php/xpath/namespace/simplexml/ Jerry Stuckle <jstucklex@attglobal.net> - 2014-09-04 20:43 -0400
Re: Extracting values from xml file using php/xpath/namespace/simplexml/ "Christoph M. Becker" <cmbecker69@arcor.de> - 2014-09-05 04:08 +0200
Re: Extracting values from xml file using php/xpath/namespace/simplexml/ Denis McMahon <denismfmcmahon@gmail.com> - 2014-09-05 02:50 +0000
Re: Extracting values from xml file using php/xpath/namespace/simplexml/ Jerry Stuckle <jstucklex@attglobal.net> - 2014-09-05 08:24 -0400
Re: Extracting values from xml file using php/xpath/namespace/simplexml/ Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-09-07 11:57 +0200
Re: Extracting values from xml file using php/xpath/namespace/simplexml/ Jerry Stuckle <jstucklex@attglobal.net> - 2014-09-07 09:54 -0400
Re: Extracting values from xml file using php/xpath/namespace/simplexml/ "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2014-09-07 23:53 +0200
csiph-web