Xpath Child & Sibling value
I'm using the following XML pattern:
<system-folder id="12345">
<name>About_Us</name> <title>About
Us</title> <dynamic-metadata>
<name>display-in-navigation</name>
<value>Yes</value> </dynamic-metadata>
<dynamic-metadata>
<name>display-in-sitemap</name>
<value>Yes</value> </dynamic-metadata>
</system-folder>
I want to use Xpath to select these
but I'm not sure how to filter so that the dynamic-metadata has the
child name with a value of "display-in-navigation" and a sibling
value node with "Yes".
The closest I've came is:
$_XPathTool.selectNodes($sib, "system-folder[ (
dynamic-metadata/name='display-in-navigation' ) and (
dynamic-metadata/value='Yes' ) ] )
Unfortunately since there are multiple dynamic-metadata/value
nodes in the XML feed, it's possible that
display-in-sitemap
could be set to yes and
display-in-navigation
could be set to no. If this
happens, my above fails.
Discussions are closed to public comments.
If you need help with Cascade CMS please
start a new discussion.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
1 Posted by Wing Ming Chan on 02 Jun, 2014 05:38 PM
Hi Matt,
Try this XPath expression:
system-folder[dynamic-metadata[name='display-in-navigation']/value='Yes']
I only tested it with XSLT, not with Velocity. But I believe it'll work.
Wing
2 Posted by Ryan Griffith on 02 Jun, 2014 06:20 PM
Hi Matt,
Wing's XPath looks spot on. One thing to keep in mind for checkbox and radio dynamic metadata fields, if no value is selected at all the
value
element will not be present. This XPath will work just fine by filtering only those with an actualvalue
element that is equal to Yes, but just something to be aware of.3 Posted by Wing Ming Chan on 02 Jun, 2014 06:25 PM
Ryan,
Thank you for reminding us to test the value first:
system-folder[dynamic-metadata[name='display-in-navigation']/value and dynamic-metadata[name='display-in-navigation']/value='Yes']
Wing
4 Posted by Ryan Griffith on 02 Jun, 2014 06:27 PM
Not a problem at all, Wing. I double-checked and confirmed that your original XPath worked as well if no item is checked.
Ryan Griffith closed this discussion on 05 Jun, 2014 01:20 PM.