Question

Im trying to find the first ancestor of an element with a specfic @id, where the ancestor has element "metaCategory" containing text...

So pseudo: Element with @id = XXXX --> Get first ancestor Where metaCategory text() is not empty

Hope this makes sense.

Structure example:

<SubFrontpage id="2049" parentID="1112" level="3" writerID="9" creatorID="1" nodeType="1107" template="1297" sortOrder="1" createDate="2010-11-02T14:41:51" updateDate="2013-10-28T10:38:41" nodeName="Demenssygdomme" urlName="demenssygdomme" writerName="Eksponent" creatorName="Webmaster" path="-1,1086,1112,2049" isDoc="">
    <shortIntro><![CDATA[bla bla bla]]></shortIntro>
    <body><![CDATA[yada yada]]></body>
    <browserTitle>
    </browserTitle>
    <date>2010-11-02T14:41:00</date>
    <showEditDate>0</showEditDate>
    <showToTop>0</showToTop>
    <showPublishedDate>0</showPublishedDate>
    <image>
    </image>
    <navigationTitle>
    </navigationTitle>
    <hideFromNavigation>0</hideFromNavigation>
    <hideFromSitemap>0</hideFromSitemap>
    <metaDescription>
    </metaDescription>
    <metaKeywords>
    </metaKeywords>
    <metaNoIndex>0</metaNoIndex>
    <metaNoIndexOnDescendents>0</metaNoIndexOnDescendents>
    <umbracoUrlAlias>
    </umbracoUrlAlias>
    <keywords><![CDATA[]]></keywords>
    <writtenBy>
    </writtenBy>
    <metaCategory><![CDATA[5991]]></metaCategory>
    <boxes><![CDATA[4105,2210,2208]]></boxes>
    <macroContainer><![CDATA[]]></macroContainer>
    <mainMacroNarrow><![CDATA[]]></mainMacroNarrow>
    <Document id="3477" parentID="2080" level="4" writerID="3" creatorID="3" nodeType="1070" template="1045" sortOrder="0" createDate="2011-01-19T09:37:18" updateDate="2011-03-03T11:01:09" nodeName="Aktører i udredningsforløbet" urlName="aktoerer-i-udredningsforloebet" writerName="Jesper Bøgel Jensen" creatorName="Jesper Bøgel Jensen" path="-1,1086,1112,2080,3477" isDoc="">
      <shortIntro><![CDATA[BLABLA]]></shortIntro>
      <body><![CDATA[YADA]]></body>
      <browserTitle>
      </browserTitle>
      <date>2011-01-19T09:37:00</date>
      <showEditDate>0</showEditDate>
      <showToTop>1</showToTop>
      <showPublishedDate>0</showPublishedDate>
      <image>
      </image>
      <navigationTitle>
      </navigationTitle>
      <hideFromNavigation>0</hideFromNavigation>
      <hideFromSitemap>0</hideFromSitemap>
      <metaDescription>
      </metaDescription>
      <metaKeywords>
      </metaKeywords>
      <metaNoIndex>0</metaNoIndex>
      <metaNoIndexOnDescendents>0</metaNoIndexOnDescendents>
      <umbracoUrlAlias>
      </umbracoUrlAlias>
      <macroContainer><![CDATA[]]></macroContainer>
      <keywords><![CDATA[3300]]></keywords>
      <boxes><![CDATA[1350]]></boxes>
      <writtenBy>
      </writtenBy>
      <linksHeading>
      </linksHeading>
      <links>
        <links />
      </links>
      <test>
      </test>
    </Document>
</SubFrontpage>
Was it helpful?

Solution

Not tested as no testing data were provided.

//@id[.="XXX"]/ancestor::*[metaCategory/text()][1]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top