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 June 11th, 2008, 11:17 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

You were already told that the '=' does not belong there so fix that first.
And if you keep insisting on posting a mix of XPath and ASP then it is difficult to help, unless you at least exactly specify which value for instance request.Form("search_by") has.
My posted sample shows you how to check the number of nodes selectNodes returns so check that for instance in your code to find out how many nodes your XPath finds.

--
  Martin Honnen
  Microsoft MVP - XML
 
Old June 11th, 2008, 12:10 PM
Authorized User
 
Join Date: Jun 2008
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have already try like this:

path="form/description[<% request.Form("search_by")%>,'<% request.Form("txtSearch")%>']//*";

I change "=" become ","

but it still error...
 Error Said that "unexpected "," "

If I remove "," the result does not show

I use ASP code inside that because I want to get the value from the text field.

 
Old June 11th, 2008, 12:17 PM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Either this for an exact match:

path="form/description[<%= request.Form("search_by")%>='<%= request.Form("txtSearch")%>']//*";

or this for a 'like' match:

path="form/description[contains(<%= request.Form("search_by")%>,'<%= request.Form("txtSearch")%>')]//*";



/- Sam Judson : Wrox Technical Editor -/
 
Old June 11th, 2008, 12:17 PM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

In
Code:
path="form/description[<% request.Form("search_by")%>,'<% request.Form("txtSearch")%>']//*";
the contains is missing so you need
Code:
path="form/description[contains(<% request.Form("search_by")%>,'<% request.Form("txtSearch")%>')]//*";
You can use ASP if you need but if you come to a forum telling others that the XPath expression does not work against your posted XML then you need to explain which values those ASP expression yield to allow others in the forum to decide where the problem is.

--
  Martin Honnen
  Microsoft MVP - XML
 
Old June 11th, 2008, 12:19 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

This is getting ridiculous. The XPath syntax isn't

form/description[title, 'value']

it is

form/description[contains(title, 'value')]

Just stop and think for ten minutes(*) next time you get an error message - or preferably before you put your hands on the keyboard.

(*) I see Sam said "for a moment", but in your case I would recommend longer than that.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old June 11th, 2008, 12:37 PM
Authorized User
 
Join Date: Jun 2008
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I try this one:

Code:
path="form/description[contains(<%= request.Form("search_by")%>,'<%= request.Form("txtSearch")%>')]//*";
and it still error and said that unknown method...

<%= request.Form("search_by")%>
to get from drop down menu which is named "search_by"

<%= request.Form("txtSearch")%>
to get from text field which is named "txtSearch"

in dropdown menu there are some values like: type, author, dates, title, etc

In text field, users can type the keyword that they want to search.

if I do not use ASP code, it should look like this:

Code:
path="form/description[contains(type,'black')]//*";
or

Code:
path="form/description[contains(author,'Someone')]//*";
or

Code:
path="form/description[contains(year,'2008')]//*";
so, because I wanna get "year, type, author" from the drop down menu, I use ASP code.
And, because I wanna get the value from the user that has been typed,
I also use ASP code to get it.


I still have no idea. Or maybe I ask this problem to ASP forum?
Am I in right place to ask my problem?

Thank you all for your helping


:)

 
Old June 12th, 2008, 05:57 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

If you are using MSXML 3 to evaluate the XPath expression you need to make sure you set
Code:
xmlDocument.setProperty("SelectionLanguage", "XPath")
before you evaluate XPath expressions with selectNodes or selectSingleNode.

--
  Martin Honnen
  Microsoft MVP - XML





Similar Threads
Thread Thread Starter Forum Replies Last Post
Word search - Count Hits bonekrusher XSLT 5 January 2nd, 2008 10:26 AM
how to use word and pdf filter in full text search connect2sandep SQL Server 2005 0 February 9th, 2006 02:00 PM
How to highlight search results in Word haiying Access VBA 0 July 25th, 2005 11:13 AM
how can i search ms-word used in c#.net project k_kalyan .NET Framework 2.0 1 February 28th, 2005 03:20 AM
Search Does not go beyond 1st word in field phungleon Classic ASP Databases 2 December 27th, 2004 08:11 PM





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