1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2004
    Rep Power

    Filtering an XML file by a string


    I'm trying to filter an XML file file by a string contained in a node.

    I'm using SimpleXML to do it. However, I can only filter by the exact value of a node, I can't filter by a part of that string. Here i my code:

    <item>The big red shoe</item>
    <item>Small red coat</item>
    PHP Code:
      $newresult $result->xpath("//all/clothes/item[.='The big red shoe']/.."); 
    It works only for the specific string 'The big red shoe'. I want to instead show all results that contain the word 'red'.

    Any ideas?

    Many thanks in advance
  2. #2
  3. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Rep Power
    30 seconds using Google:

    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".

IMN logo majestic logo threadwatch logo seochat tools logo