Wrox Programmer Forums
|
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 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 June 17th, 2004, 03:00 PM
Authorized User
 
Join Date: Jun 2004
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default MSXML - SelectNodes and XPath

I'm getting a parsing error returned when executing the xpath statement. Below is the code I am using.

-------------------------------------------------
Dim matchText : matchText="<span style='font-size:12pt; font-family:""Times New Roman""; color:#000000;'>file</span>"
...
...
Set identNodeList = itemNode.selectNodes("/item[text=""" & matchText & """]/@ident")
-------------------------------------------------

The error I get is:

------------------------------------------------
Expected token ']' found 'NAME'.

/item/text="<span style='font-size:12pt; font-family:"-->Times<--New Roman"; color:#000000;'>file</span>"]/@ident
------------------------------------------------

It seems like the quote before the text "Times" is being treated as a closing quote. I need these quotes to be part of the string I am searching for. I also tried replacing the double quotes with the escape character &quot; as follows:

------------------------------------------------
Dim matchText : matchText="<span style='font-size:12pt; font-family:&quot;Times New Roman&quot;; color:#000000;'>file</span>"
...
...
Set identNodeList = itemNode.selectNodes("/item[text=""" & matchText & """]/@ident")
------------------------------------------------

The above code executes without error but it does not select any nodes.

My question is, how do you build a xpath query that contains single and double quotes as the value you are looking for?

Please advise.


 
Old March 10th, 2005, 06:47 AM
Authorized User
 
Join Date: Jan 2005
Posts: 66
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to JelfMaria
Default

Set identNodeList = itemNode.selectNodes("/item[text=" & " & " & matchText & " &" & "]/@ident")

plz try thiz



 
Old March 10th, 2005, 06:57 AM
Authorized User
 
Join Date: Jan 2005
Posts: 66
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to JelfMaria
Default

try this:)

Set identNodeList = itemNode.selectNodes("/item[text=" & chr(34) & matchText & chr(34) & "]/@ident")

use chr(34) wherever required like if u want to search a word with double quotes like - "help"
give as chr(34) & help & chr(34)






Similar Threads
Thread Thread Starter Forum Replies Last Post
MSXML selectSingleNode for XPath with quotation Vx XML 2 March 20th, 2007 11:44 AM
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 C# 1 August 29th, 2006 09:48 AM
C# XML--SelectSingleNode/SelectNodes is failing. gijomk XML 2 August 28th, 2006 03:28 AM
XML Namespace and ASP SelectNodes werD420 Classic ASP XML 1 August 13th, 2005 04:41 AM





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