Xpath check for value and select child node

I am stuck with the follow situation for my wordpress import. What i need is to select
the ‘ResourceLink’ byt xpath. The image is related to ‘ResourceContentType’. It’s possible there
is a value 01, but also 02 (mixed in node ordering as well). I only need the ’01’ value so I need to check for this value and after selecting the resource link.

I wrote myself this xpath line;

Read More
{CollateralDetail[1]/SupportingResource[1]/ResourceVersion[1]/ResourceLink[1]}

Which works but, when ResourceContentType=02 is ordered as first I get the wrong image. I need to add
something in my xpath code to check if ResourceContentType = 01.

<SupportingResource>
<ResourceContentType>01</ResourceContentType>
<ContentAudience>03</ContentAudience>
<ResourceMode>03</ResourceMode>
<ResourceVersion>
<ResourceForm>02</ResourceForm>
<ResourceVersionFeature>
<ResourceVersionFeatureType>01</ResourceVersionFeatureType>
<FeatureValue>D502</FeatureValue>
</ResourceVersionFeature>
<ResourceVersionFeature>
<ResourceVersionFeatureType>02</ResourceVersionFeatureType>
<FeatureValue>800</FeatureValue>
</ResourceVersionFeature>
<ResourceVersionFeature>
<ResourceVersionFeatureType>03</ResourceVersionFeatureType>
<FeatureValue>563</FeatureValue>
</ResourceVersionFeature>
<ResourceVersionFeature>
<ResourceVersionFeatureType>04</ResourceVersionFeatureType>
<FeatureValue>9789043026529_covr.jpg</FeatureValue>
</ResourceVersionFeature>
<ResourceVersionFeature>
<ResourceVersionFeatureType>05</ResourceVersionFeatureType>
<FeatureValue>.0572</FeatureValue>
</ResourceVersionFeature>
<ResourceLink>
url
</ResourceLink>
<ContentDate>
<ContentDateRole>01</ContentDateRole>
<Date dateformat="00">20121214</Date>
</ContentDate>
</ResourceVersion>
</SupportingResource>

Related posts

Leave a Reply

1 comment

  1. You can add ResourceContentType checking like this :

    {CollateralDetail[1]/SupportingResource[ResourceContentType='01'][1]/ResourceVersion[1]/ResourceLink[1]}
                                           ^notice this addition^^^^