To Select a Single Value from an XML document you use the XPath Tool and the selectSingleNode method. Here is some example code to pull the title and artist from our CD Catalog data file.
<h2>My CD Collection</h2>
<table style="border: 3px solid #450084">
<tr style="background:#ccc999">
<th style="text-align:left">Title</th>
<th style="text-align:left">Artist</th>
</tr>
##GET Node
#set ( $title = $_XPathTool.selectSingleNode($contentRoot, "/catalog/cd/title").value)
#set ( $artist = $_XPathTool.selectSingleNode($contentRoot, "/catalog/cd/artist").value)
<tr>
<td>$title</td>
<td>$artist</td>
</tr>
</table>
My CD Collection
Title | Artist |
---|---|
Empire Burlesque | Bob Dylan |