Thread: [phpXML] Searching on attributes
Brought to you by:
bs_php,
nigelswinson
From: <lu...@sa...> - 2001-10-08 16:08:41
|
Hello, Sorry guys its time to fire the my_stupid_question_of_the_day() function : In the government example, the search function is pretty simple because the search is done on content if ( !empty($term) ) { // Only select those persons, in whose name or position // the search string is present. $government = $xml->evaluate( "//person/*[contains(., $term)]/.."); } else { // Select all members of the government. $government = $xml->evaluate("//person"); } How would one (one = me) proceed to do the same kind of thing with a search based on attributes especially as attributes aren't accessed directly but through an array In fact I've a file that is an agenda and I'd like to be able to search on the attribute month "name" : <agenda> <month name="January"> <event> <date/> <location> <name/> <address/> <town/> <country/> </location> <phone/> <email/> <web/> <description/> </event> </month> Thanks in advance Luc -- This message has been sent through the <phpXML/> user discussion list. To unsubscribe, please visit https://sslsites.de/mailinglisten/user/us...@li.../ |
From: <tom...@di...> - 2001-10-08 15:39:21
|
As is described (aka RTFM ;-) in the ZVON tutorial http://www.zvon.org/xxl/XPathTutorial/General/examples.html //month[@name='January'] At 11:09 PM 7/6/01 +0000, lu...@sa... wrote: ><agenda> > <month name="January"> > <event> > <date/> > <location> > <name/> > <address/> > <town/> > <country/> > </location> > <phone/> > <email/> > <web/> > <description/> > </event> > </month> > >Thanks in advance > >Luc > > >-- >This message has been sent through the <phpXML/> user discussion list. To >unsubscribe, please visit >https://sslsites.de/mailinglisten/user/us...@li.../ -- This message has been sent through the <phpXML/> user discussion list. To unsubscribe, please visit https://sslsites.de/mailinglisten/user/us...@li.../ |
From: <lu...@sa...> - 2001-10-08 16:40:48
|
Tom I read the FM several times ;-)) I tried if ( !empty($month_name) ) { $sorties = $xml->evaluate('//agenda/month[@name="$month_name"]'); } else { $sorties = $xml->evaluate('//agenda/month'); } If I use this I get a phpXML error: While parsing the XPath expression "$month_name" an empty and therefore invalid node-test has been found. The FM doesn't say what does "an empty and therefore invalid node-test has been found" mean in plain english ;-)) Luc At 23:26 06/07/01 +0000, tom...@di... wrote: >As is described (aka RTFM ;-) in the ZVON tutorial >http://www.zvon.org/xxl/XPathTutorial/General/examples.html > > > //month[@name='January'] > > >At 11:09 PM 7/6/01 +0000, lu...@sa... wrote: > >><agenda> >> <month name="January"> >> <event> >> <date/> >> <location> >> <name/> >> <address/> >> <town/> >> <country/> >> </location> >> <phone/> >> <email/> >> <web/> >> <description/> >> </event> >> </month> >> >>Thanks in advance >> >>Luc -- This message has been sent through the <phpXML/> user discussion list. To unsubscribe, please visit https://sslsites.de/mailinglisten/user/us...@li.../ |
From: <inf...@aj...> - 2001-10-08 15:44:47
|
Bonjour luc, Le samedi 7 juillet 2001 à 09:10:32, vous écriviez : lsec> '//agenda/month[@name="$month_name"]'); It's not phpXml but an error with your PHP coding : Between single quotes PHP doesn't calculate/evaluate the variables if you make this test : $month_name = 18; echo '//agenda/month[@name="$month_name"]'; You will obtain this output : //agenda/month[@name="$month_name"] To correct you must write : echo "//agenda/month[@name=\"$month_name\"]"; and you will have : //agenda/month[@name="18"] I prefer this : echo sprintf( '//agenda/month[@name="%s"]', $month_name) ; I use echo to demonstrate, you use this in strings.. (Sorry but my english is poor, I hope I help you) -- Cordialement, Daniel mailto:inf...@aj... ---------- Support-Assistance PHP/MySql de «Internet Pour Tous» http://www.i-p-t.com.fr/ :::XML/XSLT - Sablotron::: -- -- This message has been sent through the <phpXML/> user discussion list. To unsubscribe, please visit https://sslsites.de/mailinglisten/user/us...@li.../ |
From: <inf...@aj...> - 2001-10-08 16:32:40
|
Bonjour infonews, Le samedi 7 juillet 2001 à 10:05:54, vous écriviez : iac> Bonjour luc, iac> Le samedi 7 juillet 2001 à 09:59:31, vous écriviez : lsec>> $sorties = $xml->evaluate('//agenda/month[@name="%s"]', $month_name); iac> No write this : iac> $sorties = $xml->evaluate( sprintf( '//agenda/month[@name="%s"]'), $month_name); Sorry, I always have this in the reply address : us...@li..., us...@li..., us...@li..., us...@li..., us...@li..., us...@li..., us...@li..., us...@li..., us...@li..., us...@li..., us...@li..., us...@li..., us...@li..., us...@li..., us...@li..., us...@li..., us...@li... Sometimes i take care, another no ;-( I have modified my mailer to override the adress when reply ! -- Cordialement, Daniel mailto:inf...@aj... ---------- Support-Assistance PHP/MySql de «Internet Pour Tous» http://www.i-p-t.com.fr/ :::XML/XSLT - Sablotron::: -- -- This message has been sent through the <phpXML/> user discussion list. To unsubscribe, please visit https://sslsites.de/mailinglisten/user/us...@li.../ |
From: <lu...@sa...> - 2001-10-08 16:43:55
|
Daniel, This is much more efficient FM ;-) Thanks a lot by the way fore some reason $sorties =3D $xml->evaluate('//agenda/month[@name=3D"%s"]', $month_name); give an empty array while $sorties =3D $xml->evaluate('//agenda/month[@name=3D'.$month_name.']'); works OK Thanks again Luc At 07:19 07/07/01 +0000, inf...@aj... wrote: >Bonjour luc, > >Le samedi 7 juillet 2001 =E0 09:10:32, vous =E9criviez : > >lsec> '//agenda/month[@name=3D"$month_name"]'); > >It's not phpXml but an error with your PHP coding : >Between single quotes PHP doesn't calculate/evaluate the variables if >you make this test : >$month_name =3D 18; >echo '//agenda/month[@name=3D"$month_name"]'; > >You will obtain this output : //agenda/month[@name=3D"$month_name"] > >To correct you must write : >echo "//agenda/month[@name=3D\"$month_name\"]"; >and you will have : //agenda/month[@name=3D"18"] > >I prefer this : >echo sprintf( '//agenda/month[@name=3D"%s"]', $month_name) ; > >I use echo to demonstrate, you use this in strings.. >(Sorry but my english is poor, I hope I help you) >-- >Cordialement, > Daniel mailto:inf...@aj... >---------- >Support-Assistance PHP/MySql de =ABInternet Pour Tous=BB >http://www.i-p-t.com.fr/ :::XML/XSLT - Sablotron::: -- This message has been sent through the <phpXML/> user discussion list. To unsubscribe, please visit https://sslsites.de/mailinglisten/user/us...@li.../ |
From: <ph...@pe...> - 2001-10-08 13:42:21
|
On Saturday 07 July 2001 21:50, you wrote: > Daniel, > > Un petit mot ... > >Support-Assistance PHP/MySql de «Internet Pour Tous» > >http://www.i-p-t.com.fr/ :::XML/XSLT - Sablotron::: and an ISP that actually provides php with-sablot. how about that! -- This message has been sent through the <phpXML/> user discussion list. To unsubscribe, please visit https://sslsites.de/mailinglisten/user/us...@li.../ |
From: <inf...@aj...> - 2001-10-08 15:09:00
|
Bonjour phpxml, Le dimanche 8 juillet 2001 à 12:46:26, vous écriviez : >> Un petit mot ppcu> ... >> >Support-Assistance PHP/MySql de «Internet Pour Tous» >> >http://www.i-p-t.com.fr/ :::XML/XSLT - Sablotron::: ppcu> and an ISP that actually provides php with-sablot. how about that! Yes, IPT provides PHP4.0.6 with sablot 0.60 What do you want exactly. Use this private adress : "IPT - Support PHP/MySql" <php...@i-...> -- Cordialement, Daniel mailto:inf...@aj... ---------- Support-Assistance PHP/MySql de «Internet Pour Tous» http://www.i-p-t.com.fr/ :::XML/XSLT - Sablotron::: -- -- This message has been sent through the <phpXML/> user discussion list. To unsubscribe, please visit https://sslsites.de/mailinglisten/user/us...@li.../ |
From: <inf...@aj...> - 2001-10-08 15:42:54
|
Bonjour luc, Le samedi 7 juillet 2001 à 09:59:31, vous écriviez : lsec> $sorties = $xml->evaluate('//agenda/month[@name="%s"]', $month_name); No write this : $sorties = $xml->evaluate( sprintf( '//agenda/month[@name="%s"]'), $month_name); -- Cordialement, Daniel mailto:inf...@aj... ---------- Support-Assistance PHP/MySql de «Internet Pour Tous» http://www.i-p-t.com.fr/ :::XML/XSLT - Sablotron::: -- -- This message has been sent through the <phpXML/> user discussion list. To unsubscribe, please visit https://sslsites.de/mailinglisten/user/us...@li.../ |