XPath Problem - can't get the tag name of a node...

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Pesho
Forum Newbie
Posts: 12
Joined: Fri Jan 27, 2006 9:43 am

XPath Problem - can't get the tag name of a node...

Post by Pesho »

hi all,

I'm using the XPath engine of MySQL 5.1 and I have the following XML structure:

Code: Select all

<a>
<b>1</b>
<c>2</c>
<d>3</d>
</a>
What I want to extract is the tag name of the first child of <a>, e.g. I want to extract the value "b".
I know I can access the <b> node as follows:
SELECT EXTRACTVALUE(columnName,'/a/child::*[1]') from tableName;
This gives me the fist child's text, e.g. "1", but I can't figure out how to get its tag name.

I would be extremely grateful for any hint you could give!

Regards,
Pesho
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

http://dev.mysql.com/doc/refman/5.1/en/xml-functions.html wrote:The following XPath functions are not supported:
[...]
local-name()
name()
I don't see how you can get the element's name any other way in xpath.
Pesho
Forum Newbie
Posts: 12
Joined: Fri Jan 27, 2006 9:43 am

Post by Pesho »

yep, I know that, but I'm still hoping that there is some solution to my problem...
Post Reply