HighTechTalks DotNet Forums  

xpath query with more specifications

Dotnet XML microsoft.public.dotnet.xml


Discuss xpath query with more specifications in the Dotnet XML forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
C# newbie
 
Posts: n/a

Default xpath query with more specifications - 04-08-2004 , 07:03 PM






Hi group,

I've written a program which uses this XPath query:

//*[contains(translate(.,\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\ ",
\"abcdefghijklmnopqrstuvwxyz\"),"SomeString"]

as you better know, it finds and locates "SomeString" under any path within
an xml file.

The thing is that I don't know how to make it ignore those nodes which
have children and focus on nodes that have a text only. Like:

<Parent> ignore
<LastChild>SomeString</LastChild> OK
</Parent> ignore





Reply With Quote
  #2  
Old   
Gauthier
 
Posts: n/a

Default Re: xpath query with more specifications - 04-09-2004 , 01:06 AM






You can use the text() function to evaluate only the text inside your
nodes

this xpath expression show it's use:

//*[contains(text(),'SomeString')]

Hope this helps.

Gauthier Segay

C# newbie wrote:

Quote:
Hi group,

I've written a program which uses this XPath query:

//*[contains(translate(.,\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\ ",
\"abcdefghijklmnopqrstuvwxyz\"),"SomeString"]

as you better know, it finds and locates "SomeString" under any path
within an xml file.

The thing is that I don't know how to make it ignore those nodes
which have children and focus on nodes that have a text only. Like:

Parent> ignore
LastChild>SomeString</LastChild> OK
/Parent> ignore


Reply With Quote
  #3  
Old   
Alex Shirshov
 
Posts: n/a

Default Re: xpath query with more specifications - 04-09-2004 , 02:15 AM



Hello, C#!
You wrote on Thu, 8 Apr 2004 16:03:58 -0700:

Cn> I've written a program which uses this XPath query:

Cn> //*[contains(translate(.,\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\ ",
Cn> \"abcdefghijklmnopqrstuvwxyz\"),"SomeString"]

Cn> as you better know, it finds and locates "SomeString" under any path
Cn> within an xml file.

Cn> The thing is that I don't know how to make it ignore those nodes which
Cn> have children and focus on nodes that have a text only.

//*[not(*)][contains(translate(.,\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\ ",
Cn> \"abcdefghijklmnopqrstuvwxyz\"),"SomeString"]

With best regards, Alex Shirshov.



Reply With Quote
  #4  
Old   
C# newbie
 
Posts: n/a

Default Re: xpath query with more specifications - 04-09-2004 , 04:42 PM




Your answer was great! I don't know how to appreciate you. Thanks was a
great experience.


"Gauthier" <gauthier-s (AT) ifrance (DOT) com> wrote

Quote:
You can use the text() function to evaluate only the text inside your
nodes

this xpath expression show it's use:

//*[contains(text(),'SomeString')]

Hope this helps.

Gauthier Segay

C# newbie wrote:

Hi group,

I've written a program which uses this XPath query:

//*[contains(translate(.,\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\ ",
\"abcdefghijklmnopqrstuvwxyz\"),"SomeString"]

as you better know, it finds and locates "SomeString" under any path
within an xml file.

The thing is that I don't know how to make it ignore those nodes
which have children and focus on nodes that have a text only. Like:

Parent> ignore
LastChild>SomeString</LastChild> OK
/Parent> ignore




Reply With Quote
  #5  
Old   
C# newbie
 
Posts: n/a

Default Re: xpath query with more specifications - 04-09-2004 , 04:44 PM



Hi Alex,

I have received two answers one from you and the other from Gauthier.
However, both work great.
Thank for your great help. It was a huge help which you did.

Again thanks



"Alex Shirshov" <nomail (AT) mail (DOT) ru> wrote

Quote:
Hello, C#!
You wrote on Thu, 8 Apr 2004 16:03:58 -0700:

Cn> I've written a program which uses this XPath query:

Cn> //*[contains(translate(.,\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\ ",
Cn> \"abcdefghijklmnopqrstuvwxyz\"),"SomeString"]

Cn> as you better know, it finds and locates "SomeString" under any path
Cn> within an xml file.

Cn> The thing is that I don't know how to make it ignore those nodes
which
Cn> have children and focus on nodes that have a text only.

//*[not(*)][contains(translate(.,\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\ ",
Cn> \"abcdefghijklmnopqrstuvwxyz\"),"SomeString"]

With best regards, Alex Shirshov.





Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.