Report Builder 2.0, ElementPath with a field that has a space in the name


  • I'm trying to use Report Builder 2.0 to query a Sharepoint List using an XML data source.  I explicitly list the fields I want returned because otherwise I don't get all of them, due to some of them being null sometimes.  However, one of the fields I need has a space in its name.  If I do a query where I don't explicitly specify fields, I get back this as one of the fields:  ows_Pre-Req Estimate.  How can I specify this field in the ElementPath tag?  I get different errors when I try to put the field name in quotes or just leave it with a space as shown:

    <ElementPath IgnoreNamespaces="true">
    GetListItemsResponse/GetListItemsResult/listitems/data/row{@ows_Release,@ows_Theme,@ows_ID,@ows_Pre-Req Estimate}

    Here's the error I get when I leave the space in and try to run the query in Query Designer:  "The XmlDP query is invalid. Syntax error at line 1, character 105 of the ElementPath.  Expected }." I tried checking the MSDN page about ElementPath but didn't see any notes about fields with spaces.

    • Edited by cheshire137 Friday, February 05, 2010 6:47 PM Link, formatting
    Friday, February 05, 2010 6:38 PM


  • Turns out spaces have to be encoded as _x0020_, as per commenter MichealHunt on Maria's Two Cents.  The hyphen in my field name has to be encoded, too.  The easiest way I've found to translate field names as seen in Sharepoint and field names as they should be written in a Report Builder 2.0 query is to download Report Builder 3.0, design the query in there, then look at the query XML to see code like the following:

    <FieldRef Name="Pre_x002d_Req_x0020_Estimate" />
    That's the proper encoding of the field I was trying to query.  I ended up using the following ElementPath:

    <ElementPath IgnoreNamespaces="true">
    Note the "ows_" before each field name, too.  The crazy @ows_Resolve_x0020__x0023_ field name represents the field "Resolve #".
    • Marked as answer by cheshire137 Friday, February 05, 2010 7:17 PM
    Friday, February 05, 2010 7:17 PM