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 14th, 2008, 02:18 AM
Authorized User
 
Join Date: Jun 2008
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Default search value of XML element/node in general

Hello, I have a problem to search a certain word in XML but in general. I mean, we can search the word without choose the category first.

I have already run this Xpath successfully. Here is my Xpath:
path="form/document[contains(type, '<%= request.Form("txtSearch")%>')]//*";

But this Xpath only search for "type" only.

Does anyone know how if I want to search a certain word in the whole element/node of XML file? Can show me the sample of code?

Thanks




 
Old June 14th, 2008, 03:17 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Here is my Xpath:

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

Let's be clear. That is not an XPath expression. It is (ASP|JSP|PHP)-like code for generating an XPath expression.

To search for a string appearing in any text node descendant of the <document> element (but not crossing element boundaries), and to return the immediately containing elements, you could use the XPath expression

form/document//*[contains(text(), '......')]

and of course you could generate that from (ASP|JSP|PHP) in the same way.



Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Assigning node value to a href element!!!!!!!!! rakesh XSLT 4 July 25th, 2008 03:17 PM
check name of the current node element in xml arunagottimukkala XSLT 19 October 19th, 2007 04:44 AM
How to delete an element and parent node. crossedge XSLT 1 March 14th, 2006 05:10 AM
Reading every element from the specified node ROCXY XSLT 1 January 3rd, 2006 09:25 AM
How can I get the element node of an attribute cdias XSLT 2 March 15th, 2004 10:34 AM





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