What is the right syntax to use to grab a node with a colon in it?

Eric's Avatar


26 Aug, 2014 03:16 PM

I have this node called <content:encoded> and I'm trying to grab it with xpath and velocity. Is there anything special that I need to do to escape that colon?

#set ($jobs = $_XPathTool.selectNodes($contentRoot, "//item"))
#set ($count = 1)
<h3 class="career_banner">Featured Jobs</h3>

<div id="jobs-box">
    #foreach($job in $jobs)
        #if($count <= 4)
               #set( $content = $job.getChild('content:encoded'))
                    <li>$_SerializerTool.serialize(${content}, true)</li>
                #set ($count = $count + 1)   

I seem to be running into trouble with #set( $content = $job.getChild('content:encoded')), so I'm wondering if the colon has anything to do with it?

  1. 1 Posted by Ryan Griffith on 26 Aug, 2014 03:32 PM

    Ryan Griffith's Avatar

    Hi Eric,

    Accessing items that contain a namespace can be a little tricky, because the underlying library does not handle them properly. When you have a moment, try the workaround that is mentioned on this issue and let me know how it works out.

    To summarize, you have to obtain and loop over all of the children of a given Element and check the value returned by getName().

    Please let me know if you have any questions.


  2. Ryan Griffith closed this discussion on 03 Sep, 2014 08:00 PM.

Discussions are closed to public comments.
If you need help with Cascade CMS please start a new discussion.

Keyboard shortcuts


? 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


26 Aug, 2016 01:19 PM
25 Aug, 2016 03:02 PM
25 Aug, 2016 12:50 PM
24 Aug, 2016 08:43 PM
24 Aug, 2016 07:20 PM
21 Aug, 2016 01:20 PM