How to search within an xml data set?

Posted by user187580 on Stack Overflow See other posts from Stack Overflow or by user187580
Published on 2010-05-18T16:23:22Z Indexed on 2010/05/18 17:00 UTC
Read the original article Hit count: 189

Filed under:
|
|

Hi,

I have some xml data and I am trying to keyword search data. For example, if I search "some" for the following data it returns me the <id> and <title>.

<resource>
  <id>101</id>
  <title>Test Environment</title>
  <description><b>Some</b> description. </description>
  <type>classroom</type>
</resource>
<resource>
  <id>102</id>
  <title>ABC Test Environment</title>
  <description><b>Some</b> another description. </description>
  <type>classroom</type>
</resource>
...

I had a look on on xpath e.g. $xml->xpath('//title') but looks for elements only.

Basically what I need to do is to create a functionality where users can keyword search within the above data set which I receive from third party api in the above format. Any ideas how I can achieve this? using PHP/ Javascript etc.

Thanks.

© Stack Overflow or respective owner

Related posts about php

Related posts about Xml