Invalid Token when using XPath

Posted by Andy5 on Stack Overflow See other posts from Stack Overflow or by Andy5
Published on 2011-02-10T20:31:50Z Indexed on 2011/02/10 23:25 UTC
Read the original article Hit count: 271

Filed under:

Hi

I am making a modification to a web application using XPath, and when executed I get an error message - Invalid token!

This is basic what I am doing

public xmlNode GetSelection (SelectParams params, xmldocument docment)

{

xpathstring = string.format("Name =\'{0}' Displaytag = \'{1}' Manadatory=\'{2}', params.Name, params.Displaytag, params.Manadatory);

return document.selectsinglenode(xpathstring);

}

As you can see, I am making a string and setting values on the nodes I am trying to find against my xml document, and thus returning xml data that matches my parameters.

What is happening is that I am getting an xpathexeception error in Visual Studio and it says invalid token.

I do know that in the xml document that the parameters I am looking in the tags have double quotes, for example, Name="ABC". So, I thought the problem could be solved using an "\".

Can anyone help?

Update from comments

In the Xml Document, the tag has attributes where they are set as Name="ABC" Displaytag="ATag" Manadatory="true".

© Stack Overflow or respective owner

Related posts about xpath