473,387 Members | 1,573 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,387 software developers and data experts.

Extract element name by XPath expression

Hello,

I'd like to extract the name of an indirectly addressed element by
subsequently using the childs position:

001 <a>
002 <b1/>
003 <b2/>
004 <b3/>
005 </a>

I.e. I tried for the first sub-element:

001 /a/*[1]/text()

but that does return some odd characters, mainly the linefeed and some
spaces. Do you know a way to do that?

Thanks
Daniel Frey

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #1
2 15196


Daniel Frey wrote:

I'd like to extract the name of an indirectly addressed element by
subsequently using the childs position:

001 <a>
002 <b1/>
003 <b2/>
004 <b3/>
005 </a>

I.e. I tried for the first sub-element:

001 /a/*[1]/text()

but that does return some odd characters, mainly the linefeed and some
spaces.


How are you evaluating your XPath expressions then?
I think /a/*[1] would give the <b1 /> element and as it is empty
/a/*[1]/text() should give an empty nodeset.

As for accessing the name of a node there are functions in XPath to do
that, local-name() for instance e.g.
local-name(/a/*[1])
see the XPath documentation here:
<http://www.w3.org/TR/xpath#function-local-name>
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 20 '05 #2
Perfect! Thanks a lot.
Daniel

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #3

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

Similar topics

0
by: Anna | last post by:
Hi all. I hav eproblems constructing one XPath expression. Here is what I want to do: I want to choose all area tags that belong to a certain image map, having src of the image map. I don't want...
2
by: GIMME | last post by:
For starters .... If : //input is the xpath syntax to see if an element with an attribute named start_date exists ... Then what is the xpath syntax to return elements having
1
by: kurt hansen | last post by:
hi I thought that this would be easy, but maybe not so much. I want to: pass an xpath expression and a string value to a stylesheet and copy the source xml document, changing the value of...
9
by: Stefan Franke | last post by:
Hi, I've got the following simple XSLT stylesheet, that lists all the values of the elements of any given XML file. <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0"...
2
by: gimme_this_gimme_that | last post by:
What xpath expression would return the category-item having uid sps002 ? <category-list> <category> <uid>GRIDS_MAIN_CATEGORY_UID</uid> <uid-type>Categories</uid-type> <category-item-list>...
7
by: steve bull | last post by:
I have the following code snippet to read the colorRange attributes for the colorRangeSwatch in the xml file listed below. string expr = "/swatches/colorRangeSwatch/colorRange";...
1
by: FaensenD | last post by:
Consider the following XML document <root> <PersonStreet>24 Miller Street</PersonStreet> <PersonZIP>12345</PersonZIP> <PersonCity>Munich</PersonCity> <CompanyStreet>24 Miller...
1
by: Rob | last post by:
Hi, I am moving through an XML document using an XPath Navigator, and I'd like to be able to get the xpath expression for the location of the current node from the root node. Any ideas how to...
4
by: piramido | last post by:
Hello, I'm in trouble with a simple XPath expression. I've got the following XML file <?xml version="1.0" encoding="UTF-8"?> <a> <b> <c>A</c> </b>
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.