TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 06-12-2011, 12:42 AM   #1 (permalink)
The Visitor
 
OvinBovin's Avatar
 
Join Date: Jun 2011
Location: Normandy
Posts: 2
Thanks: 0
OvinBovin is on a distinguished road
Default Xpath query

Hi all,

I am looking for a function that finds a string from a RSS feed and retrieve the whole content of the matched nodes values.

I've made unsuccessfull tests using fn:matches function.

Here is my PHP code ;

$document = new DOMDocument();
$document->preserveWhiteSpace = FALSE;
$document->load("soccer-rss.xml");
$xpath = new DOMXPath($document);
$string="Liga";
$markup="title";
$query = '/rss/channel/item/' . $markup .'[fn:matches(".","' . $string .'")]';
$results = $xpath->query($query);
...

In this example I wanted to retrieve titles containing the word "Liga" from RSS titles.

When submitting query /rss/channel/item/title[fn:matches(".","Liga")] my code displays all titles, even those not containing the word "Liga".

Does anyone have any idea to solve this ?
OvinBovin is offline  
Reply With Quote
Old 06-12-2011, 02:29 PM   #2 (permalink)
The Visitor
 
OvinBovin's Avatar
 
Join Date: Jun 2011
Location: Normandy
Posts: 2
Thanks: 0
OvinBovin is on a distinguished road
Default Xpath query solution

Hi all,

I've found a solution with contains function to query by an element's enclosed text :

$query="/rss/channel/item/title[contains(.,'Liga')]";

I can get out now, I'm free

Happy Sunday,
__________________
ovInBovIn

A door is what a dog is perpetually on the wrong side of. [Ogden Nash]
OvinBovin is offline  
Reply With Quote
Old 06-21-2011, 06:17 AM   #3 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

Aha! Somebody else who loves XPath as me, I suppose Yes, the contains method will serve you well there.
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
can i insert value from another page into next page query fairytale89 Absolute Beginners 0 03-21-2010 12:25 AM
Problem executing MSSQL query in PHP trmbne2000 MySQL & Databases 2 06-30-2009 02:52 PM
Query With a C# Variable?‏ StevenF The Lounge 5 12-08-2008 05:32 AM
query question Evulness Absolute Beginners 4 04-21-2008 07:46 PM
Query caching xenon Advanced PHP Programming 4 01-29-2008 08:20 PM


All times are GMT. The time now is 12:53 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design