とりあえずphpで表現
$xmlstr = <<< XML <schedule> <person id="0" start="1203559200" end="1203601400" /> <person id="1" start="1203559201" end="1203601401" /> </schedule> XML; $xml = new SimpleXMLElement($xmlstr); $location_path = "//person[@start>=\"{$start_date}\" and @end<=\"{$end_date}\"]/@id"; //example //$start_date:1203555600 //$end_date:1203606000 $nodes = $xml->xpath($location_path); foreach ($nodes as $person_node) { $result[] = (int)$person_node['id']; } //$result: array(0, 1)
みたいにしてidが取得できた。前はXML+DOMでなんでXMLが便利なデータ形式っていえるか分からなかったけど、XML+XPathはほんとにお手軽でXMLの価値が少しは分かってくる。