Error "System.Xml.XPath.XPathException: Expression must evaluate to a node set"

No. KBA-01034-3DC3
Keywords:
Last Modified: 04.10.2009

Problem
Data Structure and Template Objects have been defined. When opening the edit newsletter page function, the above error message appears.

Solution

The field mapping expression is wrong. Verify if the field mapping expression is:

  1. A valid XPath expression
  2. Resolves to something in your HTML

Resources:

  1. Wikipedia on XPath: http://en.wikipedia.org/wiki/XPath_1.0
  2. XPath evaluator: http://b-cage.net/code/web/xpath-evaluator.html 

To use the XPath evaluator, copy the HTML into the left box (XML), copy the XPath expression into the top box and click Eval. Something should appear in the right 'Result' box, otherwise your XPath expression is wrong.

 

Example:

Fields in Datastructure

  1. Title field (type text)
  2. Text field (type HTML)

HTML




Possible Mappings

  1. For field 'Title' these mappings would be valid:
    1. //h1[@class='title']   (this approach is recommended, even if you HTML changes, the element would be found because with the class name)
    2. //div[1]/h1[1]   (this is easier to do and requires no changes in the HTML, like adding the class name, but when the HTML changes, this mapping must be updated)
    3. In this example, even //h1 would do, because there is only one h1 tag in the whole HTML. For obvious reasons, this doesn't work with more complex real world HTML.
  2. Text can be mapped in a similar way:
    1. //p[@class='text']
    2. //div[1]/p[1]
    3. //p

 


This did not help me!
Please write us an e-mail to support@customaze.de - we will help you as soon as possible.

Copyright ©2010 customaze GmbH. All rights reserved.