472,356 Members | 904 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,356 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 15141


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: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
1
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. header("Location:".$urlback); Is this the right layout the...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it so the python app could use a http request to get...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
0
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...

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.