tags:

views:

324

answers:

1

I build a xpath string based on all filled-out fields in a form submitted by a user. In my xml document, not all form fields necessarily exist as nodes. When I try to do

doc.SelectNodes(xpath);

I get an exception System.Xml.XPath.XPathException that my xpath has an invalid token.

How can I modify the xpath string to only include those fields that do exist in the xml document and disregard all the others?

+2  A: 

When you receive an invalid token error it implies there is some invalid character or invalid xpath in your query. A sample of the xml and some xpath samples would be very helpful.

Jukeman