Page 1 of 1

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

Posted: Sat Apr 14, 2007 9:18 am
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

Posted: Sat Apr 14, 2007 12:37 pm
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.

Posted: Sat Apr 14, 2007 12:52 pm
by Pesho
yep, I know that, but I'm still hoping that there is some solution to my problem...