Connecting Tech Pros Worldwide Forums | Help | Site Map

System.Xml.XPath.XPathException: 'xxxxx' has an invalid token

Newbie
 
Join Date: Aug 2007
Posts: 6
#1: Aug 31 '07
I have created XML files using BCP in SQL with FOR XML AUTO, ELEMENTS option.

When I try to databind for XML file to a GridView in ASP.NET, I get an error " 'd/Commodity Description' has an invalid token".

All I did was drag a GridView and selected the datasource as XML file. The XPath expression was selected automatically as "d/Commodity Description".

I am not sure if this is an XML question or ASP.NET. I would appreciate if any XML pro can tell me if I the XML file needs to be created with a different option or if it needs to be modified. Any help is appreciated.

I am not sure if its normal for the XML file to have Numeric values for special characters for column names. If you open the XML file below, you will notice that the space, (, %, ) characters are converted to _x0020_, _x0028_, _x0025_, _x0029_.

The XML file can be viewed at this link

The error can be viewed at this link

Moderator
 
Join Date: Mar 2006
Posts: 1,103
#2: Aug 31 '07

re: System.Xml.XPath.XPathException: 'xxxxx' has an invalid token


The invalid token is definitely the space in the name 'Commodity Description'.
Is it possible for you to change it to 'Commodity_x0020_Description' ?

Also, thanks! I always wondered which program those _x0020_ names came from.
Reply