473,395 Members | 1,458 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

System.Xml.XPath.XPathException

1
I got the error message: System.Xml.XPath.XPathException, occurred in system.xml.dll, when I tried the code below:

string lastName = "O'BRIEN";
physNode = "//ENT[@NM/LT='" + lastName.ToUpper() + "']";
XmlNode entNode2 = xmlDoc.SelectSingleNode(physNode);

It complains about the string "//ENT[@NM/LT='O'BRIEN']" having a invalid token. Please help. Thanks in advance.
Mar 28 '07 #1
2 2553
dorinbogdan
839 Expert 512MB
Welcome to TheScripts TSDN....

Before passing the physNode string, replace the single quotes with
& # 3 9 ;
(without spaces, I inserted spaces to bypass the html interpreter).
Expand|Select|Wrap|Line Numbers
  1. physNode.Replace("'", "& # 3 9 ;")
(don't forget to remove spaces )
Check the HTML codes to see the correct single quote number.

I didn't tested it, but it should work.
Anyway, let us know the result.

Dorin.
Mar 29 '07 #2
dorinbogdan
839 Expert 512MB
Hi,

Did you solve the problem?

If not, try one of these ways:
Expand|Select|Wrap|Line Numbers
  1. physNode = "//ENT[@NM/LT="" + lastName.ToUpper() + ""]";  
  2. //or
  3. physNode = "//ENT[@NM/LT]="" + lastName.ToUpper() + """;  
  4.  
and please let me know the result.

Thanks,
Dorin.
Mar 30 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Oleg Paraschenko | last post by:
Hello, might be of some interest: find with XPath over file system http://uucode.com/texts/xfind/index.html <quote> The standard UNIX utility find now supports XPath:
7
by: mike p. | last post by:
I have a docbook xml file, and am using standard docbook 1.61.3 xsl stylesheets to do xhtml transform. Transform works fine when using MSXML. When I try to do the following using asp.net 1.1: ...
1
by: alpha | last post by:
Hi Friends, When we need the xpath namespace as we can traverse the xml document using xmldocument object like using selectSingleNode or selectNodes methods. In system.xml.xpath namespace we have to...
5
by: laks | last post by:
Hi I have the following xsl stmt. <xsl:for-each select="JOB_POSTINGS/JOB_POSTING \"> <xsl:sort select="JOB_TITLE" order="ascending"/> This works fine when I use it. But when using multiple...
4
by: David Thielen | last post by:
I have the following xml: <root> <name>abc "123" xyz</name> </root> When I get an XPathNavigator to root and then call navigator.Evaluate("name = \"abc \\\"123\\\" xyz"), I get an...
3
by: Eugen Gulinsky | last post by:
Hello guys, I am having problems trying to migrate our MSXML4-compatible stylesheets containing large msxsl:script blocks to a formate understandable by System.Xml:Xsl.XslTransform. I keep...
0
by: nima | last post by:
Hi I have two tables in my database. PRODUCT and PRODUCT_GROUP. PRODUCT has a foreign key to PRODUCT_GROUP. I generated a typed dataset using VS.net and added a relationship between the two...
4
by: Daniel | last post by:
Is it possible to use regular expressions inside of an xpath statement executed by System.Xml.XmlDocument.SelectSingleNode() ? string sdoc = "<foo><bar a='1'/><bar a='2'/></foo>";...
1
by: miamikk | last post by:
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...
2
by: arunairs | last post by:
Hi, Is there a way of validating and XPath? In this case , I am accepting an XPath from the user and I need to validate the XPath syntax. Is there a regular expression available that anyone can...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.