[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[Recent Entries]
[Reply To This Message]
RE: Xpath problem
Subject: RE: Xpath problem
From: "Kanthi Damodaran" <kdsm17@xxxxxxxxxxx>
Date: Tue, 05 Mar 2002 13:41:19 +0000
|
Thanks Jeff for the reply. The problem I am having is not specifying the
location path of the node but getting the correct node from the DOM. Let me
try to explain with an example. I have the following XML DOM
<Enclosed>
<Outer>
<value>21110</value>
</Outer>
</Enclosed>
<Enclosed>
<Outer>
<value>21119</value>
</Outer>
</Enclosed>
<Enclosed>
<Outer>
<value>2111</value>
</Outer>
</Enclosed>
I want to get at the node where the value element is 2111.
ie //Outer[value='2111']
But the problem is that it goes to the node that matches just the first four
digits if it exists in the DOM ... so it goes to the node where value =
21110. So I am not able to specify that it should go to the first node that
exactly matches 2111.
Thanks
Kan
From: Jeff Beadle <Jbeadle@xxxxxxxx>
Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE: Xpath problem
Date: Mon, 4 Mar 2002 16:17:56 -0500
Hello Kan,
from a ancestor of the desired "value" attribute whose content is '2111':
//*[@value='2111']
or from anywhere:
/*//*[@value='2111']
But, be advised that these will bring back all elements (any element) that
has an attribute named "value" and whose value is '2111'.
If you expected the possiblity of many elements returned, but only care
about the first then you append another predicate to the end of the first
one to return the first node:
//*[@value='2111'][1]
or from anywhere:
/*//*[@value='2111'][1]
But since you are using "selectSingleNode" you wouldn't have to worry about
this, it'll always just return the first node from the list of elements
found.
You may want to look up some information on XPath "Predicates" and how they
work.
-Jeff
-----Original Message-----
From: Kanthi Damodaran [mailto:kdsm17@xxxxxxxxxxx]
Sent: Monday, March 04, 2002 3:30 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Xpath problem
Hi -
This might seems like a really silly question, dur to my unfamiliarity with
XPath syntax and functions. Here is the problem.
I want to specify a path to a specific value in my XML Dom ie Path =
"//value='2111' and I did this by using the selectSingleNode method of the
DOM. But the problem is that it also picks up following values '21112',
21113' etc. How do I specify that I want the node ONLY if it is '2111'?
Thanks in advance for the help.
Kan
_________________________________________________________________
Join the world's largest e-mail service with MSN Hotmail.
http://www.hotmail.com
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format
RSS 2.0 |
|
Atom 0.3 |
|
|