selectNodes, contains and whole words

Hey all,

I have the following code to get a set of nodes containing a certain search
criteria:

theSearchTermsXML.selectNodes("/Table/Row/Cell[contains(Data, 'mysearch')]")

This works fine to a point - it finds all Data nodes containing the string
'mysearch' but I need to only find the ones where it's a whole word...

So, for example, if my search text was fred, the above line of code would
include 'fred bloggs', 'frederick twoshoes', and 'winifred baker', but I
only want to get back the one with 'fred' as a whole word, ie, 'fred
bloggs'.

I've tried
theSearchTermsXML.selectNodes("/Table/Row/Cell[contains(Data,
'\Wmysearch\W')]")

and

theSearchTermsXML.selectNodes("/Table/Row/Cell[contains(Data,
'\bmysearc\bh')]")

but both return 0 length.

Any ideas are more than welcome.

Thanks
Andrew


0
1/7/2004 4:15:04 PM
dotnet.xml 7266 articles. 0 followers. Follow

4 Replies
351 Views

Similar Articles

[PageSpeed] 28

Andrew Parsons wrote:

> I have the following code to get a set of nodes containing a certain search
> criteria:
> 
> theSearchTermsXML.selectNodes("/Table/Row/Cell[contains(Data, 'mysearch')]")
> 
> This works fine to a point - it finds all Data nodes containing the string
> 'mysearch' but I need to only find the ones where it's a whole word...

theSearchTermsXML.selectNodes("/Table/Row/Cell[
contains(Data, concat(' ','mysearch', ' ')]")

And don't forget about "Done with mysearch." option.

Alternatively take a look at EXSLT.NET 
(http://workspaces.gotdotnet.com/exslt) - it contains regexp extension 
functions like regexp:test(), regexp:match() etc.
-- 
Oleg Tkachenko
XML Insider
http://www.tkachenko.com/blog
0
Oleg
1/7/2004 4:40:55 PM
Hi Oleg,

Unfortunately using that kind of method only works if the word is surrounded
by spaces - what if it's the start of the term, or the end? What if it is
followed by some sort of punctuation character? Can I use special characters
instead of spaces?

And I am not sure what you mean about "Done with mysearch" option. Could you
please point me to some doco on that?

Ta
Andrew

"Oleg Tkachenko" <oleg@NO!SPAM!PLEASEtkachenko.com> wrote in message
news:OgzCMzT1DHA.2156@TK2MSFTNGP12.phx.gbl...
> Andrew Parsons wrote:
>
> > I have the following code to get a set of nodes containing a certain
search
> > criteria:
> >
> > theSearchTermsXML.selectNodes("/Table/Row/Cell[contains(Data,
'mysearch')]")
> >
> > This works fine to a point - it finds all Data nodes containing the
string
> > 'mysearch' but I need to only find the ones where it's a whole word...
>
> theSearchTermsXML.selectNodes("/Table/Row/Cell[
> contains(Data, concat(' ','mysearch', ' ')]")
>
> And don't forget about "Done with mysearch." option.
>
> Alternatively take a look at EXSLT.NET
> (http://workspaces.gotdotnet.com/exslt) - it contains regexp extension
> functions like regexp:test(), regexp:match() etc.
> -- 
> Oleg Tkachenko
> XML Insider
> http://www.tkachenko.com/blog


0
1/7/2004 11:27:54 PM
"Andrew Parsons" <newsreader@parsonsdesigns.com> wrote in message
news:egUrkXX1DHA.2336@TK2MSFTNGP09.phx.gbl...
> Hi Oleg,
>
> Unfortunately using that kind of method only works if the word is
surrounded
> by spaces - what if it's the start of the term, or the end? What if it is
> followed by some sort of punctuation character? Can I use special
characters
> instead of spaces?

Andrew,

This is not possible to select with a single XPath 1.0 expression.

If you do this inside an XSLT transformation you coud use the
"str-split-to-words" template from FXSL. It produces a node-set of nodes,
each containing as its text child one of the words of a given string. A
parameter string contains all possible characters to be used as delimiters.


Dimitre Novatchev.
FXSL developer, XML Insider,

http://fxsl.sourceforge.net/ -- the home of FXSL
Resume: http://fxsl.sf.net/DNovatchev/Resume/Res.html


0
dnovatchev (74)
1/8/2004 5:51:54 AM
Andrew Parsons wrote:

> Unfortunately using that kind of method only works if the word is surrounded
> by spaces - what if it's the start of the term, or the end? What if it is
> followed by some sort of punctuation character? Can I use special characters
> instead of spaces?
Sure. Alternatively use regexp or select all "mysearch" occurences and 
check out characters just before and after. Or use str-split-to-words 
template as Dimitre suggested.

> And I am not sure what you mean about "Done with mysearch" option.
Exactly what you said - when the word to search is last one in a sentence.
-- 
Oleg Tkachenko
XML Insider
http://www.tkachenko.com/blog
0
Oleg
1/8/2004 11:17:09 AM
Reply:

Similar Artilces:

forward or reply of messages containing "numbered lists"
I posted the following yesterday as a reply to an old posting (Nov). Since then I have confirmed that this problem (like similar ones) is associated with using WORD as my email editor. Deselecting WORD solves the problem. If anyone has an alternate solution, please post. Thanks. ~bit ================================================= I recently discovered similar (but not identical) behavior with my Outlook 2002 on XP SP2: 1) I send an HTML email (Word is the editor) with a numbered list of items (just like I'm using here) 2) The recipient responds with comments inserted after e...

time zone wording
Hi! Can anybody tell me how the time zone wording which appears when a meeting request is received as a message be changed? It appears as 11:00 AM (GMT+04:00) Abu Dhabi,Muscat. I want to change the latter part. Thanks Chris. ...

Trying to delete multiple cells that contain a specific word (not equation)
Version: 2008 Operating System: Mac OS X 10.5 (Leopard) I've had to export a form from QuickBooks Online to Excel so I could manipulate it. Within a column there are 115+ cells that contain a specific word that I need to delete all those cells. Is there something as easy as find and delete, rather than find and replace? I can't believe that I have to delete each cell individually. On 3/9/10 10:52 AM, JeanM@officeformac.com wrote: > Version: 2008 Operating System: Mac OS X 10.5 (Leopard) I've had to > export a form from QuickBooks Online to Excel so I could manipulate ...

XPath contains() function
My goal is to select some XPath nodes based on whether their values (text) contain a string passed as argument. To achieve this I use the contains() function of XPath in an XpathExpression. For example, given the following fragment... <code> <Exprs> <Expr>red fox</Expr> <Expr>jump over</Expr> <Expr>box</Expr> </Exprs> </code> .... I want to select the second <Expr> and test whether it contains the string argument "jump": (I am passing values to the contains() function dynamically, but here I will use...

Word 2000 Mail Merge: Word found no mail merge fields
Hello everybody, As the subject says, I am trying to create a form letter in Word 2000 from an Excel 2000 spreadsheet, but when I try to to open the data source, I get the following error: "Word found no mail merge fields in your main document". How do I create mail merge fields? Can anybody help me? Thanks in advance. Brian Brian Harvey wrote: > Hello everybody, > > As the subject says, I am trying to create a form letter in Word 2000 > from an Excel 2000 spreadsheet, but when I try to to open the data > source, I get the following error: "Word found no ma...

Read Text from WOrd
Hi, I have written a code to convert word file to text and store it in the database. I am using the below code to open the document but the code completely hangs there. Can you please help me what I am doing wrong? oDoc = oWordApplic.Documents.Open(ref fileName, ref missing,ref readOnly, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref isVisible,ref missing,ref missing,ref missing); Regards Sunil The first parameter expects a file path. How are you 'reading from the database'? -- Vapordan ...

How do I print a whole excel file in colour when the default is mo
Our printer defaults are set to print all docs in monochrome. On a multi sheet excel file, If I click print then choose entire workbook and then change my print options to colour, it prints the first worksheet in colour, and all the others in mono. How can I get them all to print in colour? Thanks Chris Print options are sheet-related, not book-related. First group the sheets by right-click on the first sheet tab and "select all sheets". File>Page Setup>Sheet. Uncheck "black and white". Ungroup the sheets by right-click and "ungroup sheets" Now F...

Microsoft Word Problems.
I have recently been getting a message when I exit Outlook 2003 or Word from Office 2003. Whe I exit either program I get a message the "Normal" Document already exists and If I want to save it. I select No but I get the same message each time I exit Word or Outlook. I have ran spyware and virus programs suspecting a problem but nothing shows up Any Suggestions? On Feb 20, 10:52 am, "In the Dog House" <rick...@yahoo.com> wrote: > I have recently been getting a message when I exit Outlook 2003 or Word from > Office 2003. Whe I exit either program I ge...

msg:"name of imported entity already exists" should contain name
When I import an XML file that includes several modifications like entity renamings(should be ported back to an older setup status), the following error occured: "The name of the imported entity already exists. Please specify another name". It would be more easier to find what entity or attribute can not be added/renamed if there would be a way to configure the system for getting more detailed error information (what entity/ what attribute affected). ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To v...

hiding a comment in Word 2007
how can I get a pop-up comment (like you can in Excel) which comes up when you rest the mouse pointer over it, but disappears again when you move the mouse pointer away from it. I have Word 2007 . Hello Chris chris wrote: > how can I get a pop-up comment (like you can in Excel) which comes up when > you rest the mouse pointer over it, but disappears again when you move the > mouse pointer away from it. I have Word 2007 . MVP Jay Freedman has found an interesting "hack" for this sort of thing in Word: <quote> Every once in a while, somebody asks f...

nonsense words
where can i download those nonsense words or fake text to fill up a text box for example. help and thanks. Google for "lorem ipsum" and you'll get plenty to choose from. -- Hugs, Erika Just go to the Symantec website and download the text from any pages as it is all lies, garbage, false claims etc. etc. and just a lot of nonsense sales department meaningless words. -- ...

Excel/Word ILC and barcode font
Hi Folks Would like to have an excel spreadsheet or word document with the ILC formatted as a barcode 128B... is this possible? Check here: http://www.barcode-1.net/pub/russadam/fonts.html -- Jocelyn "Danny" wrote: > Hi Folks > > Would like to have an excel spreadsheet or word document with the ILC > formatted as a barcode 128B... is this possible? > > > Sorry - I was not really specific. We use the free version of code 39 from this site. It is a Word font that you install to write or xfer your ILCs into barcodes. -- Jocelyn "Danny&quo...

Where are the Word Templates?
I'm using Word Office 2007 and can't find the word templates anymore. Are they still available? Sorry, this newsgroup is for questions about Access, the database product that's part of Office Professional. You'd be best off reposting your question to a newsgroup related to Word. -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "idahoshippers" <idahoshippers@discussions.microsoft.com> wrote in message news:92CF36C9-C5E2-4B06-B59B-14A902539EA0@microsoft.com... > I'm using Word Office 2007 and can't find the wor...

Hyperlink from Word 2007 to PowerPoint 2007
Hello, I have been at this for hours and hours and i still cant figure this out so any advice would be helpful. I am trying to create a hyperlink in Word 2007 (.docx) to a specific power point (.pptx) slide (slide 8 titled Award, to be exact). So i have the hyperlink created and i can get to the power point but it always opens the first slide. Here are the different hyperlinks i have used and they all open the first slide (assume the Word doc and the PPT are both on the desktop). * You cannot click the Bookmark button in the 'Edit Hyperlink' screen because it gives ...

undo saving a document in Word
I changed a Word document and hit save. Oops!! Now I want to revert to the pre-editted version. Can I get it back? As long as you haven't closed the document, you can use Undo: press Ctrl+Z until you get back the version that you want. -- Stefan Blom Microsoft Word MVP "sillytilly" <sillytilly@discussions.microsoft.com> wrote in message news:D24714A3-15E7-41F3-8C75-D24F14597DB6@microsoft.com... >I changed a Word document and hit save. Oops!! Now I want to revert to the > pre-editted version. Can I get it back? If you realize the mis...

SelectNodes
Has anyone got an implementation of SelectNodes that works for CF? OpenNetCF doesn't seem to have one... Thanks, Peter Peter, The thing i do is simply get the XmlNodeList of children of the current node I wish to evaluate, then iterate through each til i have the child node i wish. Then get the next XmlNodeList of this current node, etc etc, until i get the node i need. It's a pain, looks a bit messy in the code, but works reasonably well. The reason no one's done this is because of the restriction of resources on a CE device... Ideally you'd want to move away from XML an...

Who could tell me about container?
Hello all: I know when the container is running,it want to search the COM in register table and load them,I want to know where they need to seach like as word,excel and ie? thanks. Lee Tow wrote: > Hello all: > I know when the container is running,it want to > search the COM in register table and load them,I want > to know where they need to seach like as word,excel and ie? thanks. When you call CoCreateInstance to create a COM object the registry search is done by COM, not by the caller. -- Scott McPhillips [MVP VC++] ...

Word Send to Mail Recipient loses some images
I'm using Word (Office 03) to create a newsletter to be emailed monthly to number of people through File/Send to/Mail Recipient. I use Outlook for email, on a Win XP SP2 IE7 machine. First month worked fine (with only 2 images). This month, when I run the test (sending to myself), two of the images (pictures) go through but the other 3 don't. There isn't even placeholder or "x" or anything where picture used to be when it's received. And Outlook only shows 2 images as attachments in its info about the incoming message. Indeed, the "sent" version of the...

How to I advance filter to remove rows containing partic string of text?
Is this possible? I know how to filter to include strings of text but I don't know how to filter so that rows containing a certain email address domain name are not visible in the filetered results. Many thanks if anyone's able to assist! Dave Hi one way: use a helper column with a formula like =IF(ISNUMBER(FIND("domain.com",A1)),1,0) and filter with this column >-----Original Message----- >Is this possible? > >I know how to filter to include strings of text but I don't know how >to filter so that rows containing a certain email address domain name &...

Highlighting Disappears When MS Word 2007 Document is E-Mailed
I have spent hours highlighting a document in Office 2007 Word running on XP. When I send it to my home computer running the same Office 2007 Word running on W7, the highlighting is gone. What is causing this? How can it be fixed? ...

using applescript to save as word 2004 format
Version: 2008 Operating System: Mac OS X 10.6 (Snow Leopard) Processor: Intel How can I save in word 2004 format with applescript and word 2008 Why do you need Apple Script? File> Save As, select Word 97-2004 Document (.doc) from the Format: list. If it's a matter of needing to use that format routinely set it as the default format in Word> Preferences> Save. If your needs are more complex than those options address you'll have to provide a far more complete, detailed & accurate description of them before anyone can even consider whether an Apple Script solut...

MM from Word in HTML Format
I am using MS Office 2002. When I do a mail-merge from MS Word to email, it works fine as long as I use 'Plain Text' as the format. It accesses Outlook and sends the messages. However, if I use HTML format, it acts as though it is sending something, but the messages never get sent. Does anyone know what my problem might be? Brian, I seem to have the same problem in Offic 2003. When I do an email merge from Word, the screen flickers at the end but there is no record of the emails having been sent in Outlook, i.e., they are not in the Sent folder. I've tried looking around...

templates for shipping containers
I was looking for a template or such to mimic a shipping container. 8x40 or 8x20 to use for packing and stacking. Any Ideas? Maybe for visio? I have not come across any yet, but you can use clipart or other images. Depending on how the other shapes look (are they perspective or a flat on view?) The images at one of these sites may be a start. http://www.sosconsultants.com.au/customer_information_ocean.php http://www.freightraders.co.nz/containerspecs.html John... Visio MVP Need stencils or ideas? http://visio.mvps.org/3rdparty.htm Need VBA examples? http://visio.mvps.org/VBA.htm...

Delete a row if it contains only zeros
Hey, Is it possible to delete an entire row if it contains only zeros s that the row underneath moves up. I would like this to be able t happen automatically or at the click of one button. Is this possible? Thanks -turner200 -- turner200 ----------------------------------------------------------------------- turner2000's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=1477 View this thread: http://www.excelforum.com/showthread.php?threadid=26444 Here is a script I've used for this purpose. Sub RemoveZeroRows() Application.ScreenUpdating = False Dim X ...

Open correct version of Excel in Word
I have Word 2003, Excel 2003 and as of today Excel 2007. In a Word macro, I am using: Set myExcel = GetObject(, "Excel.application") and if that errors because Excel isn't open, an error handler with: Set myExcel = CreateObject("Excel.application") Now when I run my Word macro even if I have Excel 2003 open, the GetObject does not find that Excel is open and will go to the CreateObject and create an instance of Excel using Excel 2007. Is there a way to force it to open the spreadsheet in Excel 2003? GrannyM wrote: > I have Word 2003, Excel 2003 ...