1

オンライン xpath ツールを使用して以下の xml に対して動作するように以下の xpath を取得できますが、「式はノード セットに評価する必要があります」というメッセージが表示されます。.NET 4.5 の例外

xpath:

//*[starts-with(name(.), "childnode")[identification/text()='xyz']]

xml:

<rootnode>
    <childnode1234>
        <identification>xyz</identification>
    </childnode1234>
    <childnode3456>
        <identification>abc</identification>
    </childnode3456>
 </rootnode>

期待される結果は

<childnode1234>
            <identification>xyz</identification>
        </childnode1234>
4

2 に答える 2

4

変更するだけです:

//*[starts-with(name(.), "childnode")[identification/text()='xyz']]

:

//*[starts-with(name(.), "childnode")][identification/text()='xyz']

テストされていない明らかにバグのある "no name" "online xpath tools" を避けることをお勧めします

于 2013-01-26T03:58:58.910 に答える
3

オンラインの実装は緩すぎます。Microsoft XPath は正しくstarts-with()、ノード セットではなくブール値として評価されます。試す

//*[starts-with(name(.), 'childnode') and identification/text()='xyz']
于 2013-01-26T03:09:10.513 に答える