0

私はこのようなxmlの外観を得ました

<Details>
  <UserResource>
    <ResourceGroup>AJD-IPSP1</ResourceGroup>
    <ResourceType>master</ResourceType>
    <Access>r</Access>
    <UseSOAPFault>soap </UseSOAPFault>
  </UserResource>
  <UserResource>
    <ResourceGroup>AJD-VME1</ResourceGroup>
    <ResourceType>trx</ResourceType>
    <Access>r</Access>
    <UseSOAPFault>soap </UseSOAPFault>
  </UserResource>
  <UserResource>
    <ResourceGroup>AJD-VME10</ResourceGroup>
    <ResourceType>trx</ResourceType>
    <Access>r</Access>
    <UseSOAPFault>soap </UseSOAPFault>
  </UserResource>
  <UserResource>
    <ResourceGroup>AJD-VME11</ResourceGroup>
    <ResourceType>trx</ResourceType>
    <Access>r</Access>
    <UseSOAPFault>soap </UseSOAPFault>
  </UserResource>
</Details>

私が達成しようとしていることは次のとおりです。

/Details/UserResource[ResourceGroup="AJD-VME10" or ResourceGroup="AJD-VME1"]

結果は

  <UserResource>
    <ResourceGroup>AJD-VME1</ResourceGroup>
    <ResourceType>trx</ResourceType>
    <Access>r</Access>
    <UseSOAPFault>soap </UseSOAPFault>
  </UserResource>
  <UserResource>
    <ResourceGroup>AJD-VME10</ResourceGroup>
    <ResourceType>trx</ResourceType>
    <Access>r</Access>
    <UseSOAPFault>soap </UseSOAPFault>
  </UserResource>

どうすればこのxpathを行うことができますか?

1 つの xpath を使用するだけでこれを実行したいと考えています。

4

3 に答える 3

0

これを行う簡単な方法を次に示します。for ループに慣れている場合は、UserResources のそれぞれをループして、ResourceGroup/text() が用語と等しいかどうかを確認できます。

    let $x :=
<Details>
  <UserResource>
    <ResourceGroup>AJD-IPSP1</ResourceGroup>
    <ResourceType>master</ResourceType>
    <Access>r</Access>
    <UseSOAPFault>soap </UseSOAPFault>
  </UserResource>
  <UserResource>
    <ResourceGroup>AJD-VME1</ResourceGroup>
    <ResourceType>trx</ResourceType>
    <Access>r</Access>
    <UseSOAPFault>soap </UseSOAPFault>
  </UserResource>
  <UserResource>
    <ResourceGroup>AJD-VME10</ResourceGroup>
    <ResourceType>trx</ResourceType>
    <Access>r</Access>
    <UseSOAPFault>soap </UseSOAPFault>
  </UserResource>
  <UserResource>
    <ResourceGroup>AJD-VME11</ResourceGroup>
    <ResourceType>trx</ResourceType>
    <Access>r</Access>
    <UseSOAPFault>soap </UseSOAPFault>
  </UserResource>
</Details>


return $x/UserResource[ResourceGroup="AJD-VME10" or ResourceGroup="AJD-VME1"]
于 2013-08-20T17:17:02.593 に答える