473,385 Members | 1,521 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

xpath query with more specifications

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


Nov 12 '05 #1
4 3337
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


Nov 12 '05 #2
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.
Nov 12 '05 #3

Your answer was great! I don't know how to appreciate you. Thanks was a
great experience.
"Gauthier" <ga********@ifrance.com> wrote in message
news:ua**************@TK2MSFTNGP10.phx.gbl...
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

Nov 12 '05 #4
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" <no****@mail.ru> wrote in message
news:ev**************@TK2MSFTNGP10.phx.gbl...
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.

Nov 12 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Joshua Beall | last post by:
Hi All, I have a task that should be very simple but I'm running into trouble. All I want to do is query a document using XPath, and save the resulting XML in a string. Here's that I am trying...
1
by: bdinmstig | last post by:
I refined my attempt a little further, and the following code does seem to work, however it has 2 major problems: 1. Very limited support for XPath features Basic paths are supported for...
6
by: 0wl | last post by:
Hi, I am trying to get the value of child from xmlstr = """<p:root xmlns:p="http://tempuri.org/string"><p:child DataType="String">Hellpppp</p:child></p:root>""" using...
13
by: tfsquare | last post by:
All, I am new to XSLT and having some problems understanding the syntax of XPath which selects nodes in the XML document. Consider this bit of XML, which contains three outer XML elements. ...
8
by: Terry P | last post by:
Are there any tools (java classes, tag libraries) which can translate xpath statements into a SQL query? Given an xpath query which has a predicate that filters node values or attributes, I want...
3
by: IMS.Rushikesh | last post by:
Hi Friends, I need a XPath query, whcih ll return me subset of data.... check below xml stream <label id="MyExpenseDetails_lbl" xlink:role="terseLabel">Short Expense Details</label> <label...
10
by: Michael C# | last post by:
OK, here's the deal. I have a small XML file that represents a small database table. I load it into a System.XML.XMLDocument. So far so good. I run an XPath query against it to retrieve all the...
3
by: Greg | last post by:
Hi, I want to create a web based interface that uses a form + Javascript (in an XHTML namespace) to construct an XPath to query and modify the attributes of some SVG (in an SVG namespace). ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.