I tried with the following xpath and it worked. Thanks to you Paul for your help!!
//sectionelement/packagesection[@navTitle="Gas Daily"]/sectionelement/packagesection[descendant::story[@id=$id] or descendant::analytic[@id=$id]]
سؤال
I have the following XML structure. I can identify the <story contenttype="News" id="cbc655617-ba25-4629-b2a2-073ba2369758">
nodes highlighted and I need to reach the <packagesection id="264311652" navTitle="News">
nodes highlighted through XPath. Can you please help out with an XPath expression which can identify the same? I would not be able to use the navTitle attribute as it is dynamic but I only know that the packagesection node has to be the first level child of the topmost parent for a story node
<?xml version="1.0" encoding="UTF-8"?>
<package id="cfc35dc14-5345-42a4-b4f9-0b833e3fde3a">
<title>Gas Daily</title>
<sectionelement>
<packagesection id="264311518" navTitle="Gas Daily">
<sectionelement>
<packagesection id="264311652" navTitle="News">
<sectionelement>
<packagesection id="264679044" navTitle="Test1">
<sectionelement>
<packagesection id="264679046" navTitle="Test2">
<sectionelement>
<topicref format="xml"
href="cbc655617-ba25-4629-b2a2-073ba2369758" id="264679396"
sequence="1" type="story">
<story contenttype="News"
id="cbc655617-ba25-4629-b2a2-073ba2369758">
<slug>test_arko_20140502_special_byline</slug>
<storyTitlealts>
<headline>test_arko_20140502_special_byline</headline>
</storyTitlealts>
<lead>test_arko_20140502_special_byline</lead>
<storybody>
<p id="43102552-91a9-44a5-af4a-72b742460a5b">test_arko_20140502_special_byline</p>
</storybody>
</story>
</topicref>
</sectionelement>
</packagesection>
</sectionelement>
<sectionelement>
<topicref format="xml"
href="c177f4ddd-e983-4730-b835-c7724178b223" id="264679820"
sequence="2" type="story">
<story contenttype="News"
id="c177f4ddd-e983-4730-b835-c7724178b223">
<slug>nothing</slug>
<storyTitlealts>
<headline>nothing</headline>
</storyTitlealts>
<lead>nothing</lead>
<storybody>
<p id="d558b9ac-5b28-4690-bb0c-664ccbe14e8f">nothing</p>
</storybody>
</story>
</topicref>
</sectionelement>
</packagesection>
</sectionelement>
</packagesection>
</sectionelement>
<sectionelement>
*<packagesection id="264679052" navTitle="Test5">*
<sectionelement>
<topicref format="xml" href="c16f1fca2-31ed-4973-b201-a5a089c788a6"
id="264679826" sequence="12" type="story">
**<story contenttype="News" id="c16f1fca2-31ed-4973-b201-a5a089c788a6">**
<slug>test story stringer3</slug>
<storyTitlealts>
<headline>test story stringer3</headline>
</storyTitlealts>
<lead>test story stringer3</lead>
<storybody>
<p id="c5d5c883-d860-46fa-b035-64c13a5fcd23">test story stringer3</p>
</storybody>
</story>
</topicref>
</sectionelement>
</packagesection>
</sectionelement>
</packagesection>
</sectionelement>
</package>
المحلول
I tried with the following xpath and it worked. Thanks to you Paul for your help!!
//sectionelement/packagesection[@navTitle="Gas Daily"]/sectionelement/packagesection[descendant::story[@id=$id] or descendant::analytic[@id=$id]]