Jump to content

XPath Problem :(


Pesho

Recommended Posts

hi all,

 

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

 

<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

 

Link to comment
Share on other sites

I got the following information from the mysql website:

 

Note that ExtractValue() returns only CDATA, and does not return any tags that might be contained within a matching tag, nor any of their content (see the result returned as val1 in the following example).

 

http://dev.mysql.com/doc/refman/5.1/en/xml-functions.html#function_extractvalue

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.