2

誰でも私を助けることができますか?
基本的に私はXMLファイルを持っています

<AB NAME="A Quick Brown">
    ..some multiple node inside here
</AB>
<AB NAME="Fox Jumps Over">
    ..some multiple node inside here
</AB>
<AB NAME="The Lazy Dog">
    ..some multiple node inside here
</AB>
<AB NAME="The Quickbox">
    ..some multiple node inside here
</AB>

の属性で文字列を<AB> 検索して、この例の文字列全体と同様に TRUE の文字列を検索する必要があります。動作します

$string = "A Quick Brown";
$result = $xml->xpath("AB[@NAME ='$string']");

しかし、検索する必要があるのは"Quick"、たとえば単語だけです

  $string = "Quick";
 // $result = $xml->xpath("AB[@NAME ='$string']");

ABの属性で、私は

<AB NAME="Fox Jumps Over">
    ..some multiple node inside here
</AB>

私のxmlの一部。
任意の提案、およびコメントは大歓迎です。前もって感謝します!

4

1 に答える 1

2

contains()クエリでの使用を見てください。

AB[contains(@NAME, 'Quick')]
于 2013-05-28T07:42:39.147 に答える