Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XML
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old March 20th, 2007, 11:03 AM
Vx Vx is offline
Registered User
Join Date: Mar 2006
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default MSXML selectSingleNode for XPath with quotation

I need to extract element from a document in case inner text node contains certain sequence of characters.
The problem is that I can't do this in case the sequence contains quotation mark.

causes "A string literal was not closed" error in Microsoft XML parser 3.0. Of course I could use single quotation marks instead of double ones for string termination, but then the same problem would be for single quotation mark inside the string to search.

Thanks in advance

Old March 20th, 2007, 11:28 AM
mhkay's Avatar
Wrox Author
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts

XPath 2.0 allows a quote within a string to be escaped by doubling it (as in SQL) (not by escaping with "\" as in C or Java).

XPath 1.0 provides no such mechanism. You can write ' within a string delimited by ", or " within a string delimited by '. If you want both, you have to use concat():

text() = concat("He said,", '"', "I won't", '"')

Michael Kay
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Old March 20th, 2007, 11:44 AM
Vx Vx is offline
Registered User
Join Date: Mar 2006
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts


Thanks a lot.

Similar Threads
Thread Thread Starter Forum Replies Last Post
SelectSingleNode throwing exception: anup_daware .NET Framework 2.0 1 February 3rd, 2008 12:04 PM
SelectNodes, SelectSingleNode weirdness dantell BOOK: Professional Ajax ISBN: 978-0-471-77778-6 1 October 19th, 2006 12:39 PM
C# XML--SelectSingleNode/SelectNodes is failing. gijomk XML 2 August 28th, 2006 03:28 AM
Quotation NEO1976 XML 5 July 19th, 2006 10:00 AM
MSXML - SelectNodes and XPath billy_bob_the_3rd Beginning VB 6 2 March 10th, 2005 06:57 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.