Xpath help

steelej's Avatar

steelej

13 Sep, 2012 02:53 PM

I'm working on something new. I have a php-page putting out xml from a database query. I'm now setting out to script my pages using the feed. I've attached an xml of the feed and the script I'm starting with. I think this is something in the x-path I'm not seeing yet. I'm not pulling data from the feed.

Can someone lend a hand and point out my blind spot?

  1. 1 Posted by steelej on 13 Sep, 2012 03:01 PM

    steelej's Avatar

    I forgot to attach the xml of the page displaying the feed. I know the problem is that I'm trying to pull the last name from the data-structure of the page and use that value to select the expert from the feed.

  2. 2 Posted by Ryan Griffith on 13 Sep, 2012 04:03 PM

    Ryan Griffith's Avatar

    Hi,

    Based on your page XML, you will need to add a block chooser to your page's Data Definition so that you also have access to the XML from the feed. Also, in order for your Format to gain access to the Block's content, you will need to specify a Render Content Depth for the block chooser field (try using a value of 4).

    For example, say you've added a block chooser called expertFeed, something like the following Format should do the trick:

    #set ($id = $_XPathTool.selectSingleNode($contentRoot, "//system-data-structure/lname"))
    #set ($exp = $_XPathTool.selectSingleNode($contentRoot, "//expertFeed/content/system-page/expert[lname='${id.value}']"))
    
    #set ($fname = $exp.getChild("fname").value)
    #set ($lname = $exp.getChild("lname").value)
    #set ($title = $exp.getChild("title").value)
    #set ($dept = $exp.getChild("dept").value)
    
    <div class="article-header"><!--start article-header div-->
      <h1 class="expert-name">${fname} ${lname}</h1>
      <p class="italic">${title}<br />
      ${dept}</p>
    
      <div class="addthis_toolbox addthis_default_style addthis_16x16_style" id="addthis"><!-- Start AddThis Button  -->
        <a class="addthis_button_preferred_1" ></a>
        <a class="addthis_button_preferred_2" ></a>
        <a class="addthis_button_preferred_3" ></a>
        <a class="addthis_button_preferred_4" ></a>
        <a class="addthis_button_preferred_5" ></a>
        <a class="addthis_button_compact" ></a>
      </div>
      <!-- End AddThis Button -->
    </div><!--end article-header div-->
    
  3. 3 Posted by steelej on 13 Sep, 2012 04:52 PM

    steelej's Avatar

    Ryan,
    That helps. I have the feed xml in the page now but with your script, for some reason I'm still not pulling data.

  4. 4 Posted by steelej on 13 Sep, 2012 05:04 PM

    steelej's Avatar

    I got it. Thanks. I had named the block chooser expertfeed, not expertFeed. All set now.

    I appreciate your help.

  5. steelej closed this discussion on 13 Sep, 2012 05:05 PM.

Comments are currently closed for this discussion. You can start a new one.

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