V
V
vegarulez2015-12-11 22:20:21
MySQL
vegarulez, 2015-12-11 22:20:21

Mysql xml ExtractValue attribute how?

there is a construction of the form

<xml>
<a id="1"><b c="2" d="abc"/>foo</a>
<a id="2"><b c="5" d="bcd"/>bar</a>
...
<a id="n"><b c="x" d="yyy"/>foobar</a>
</xml>

The question is how to work with attributes, and not node values, using ExtractValue and UpdateXML?
Everywhere in all descriptions, work with foobars is described, but nowhere could I find how I can get and write the values ​​of the c and d attributes in a mysql query.
Please tell me this is possible???
in the description: dev.mysql.com/doc/refman/5.7/en/xml-functions.html
this line is very confusing:
Important
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).
Those. only the value of the branches and no attributes to pull out nizya ???
those. in my case, I need to get the values ​​in the c and d attributes, for example, if id=1. How to do it - tell me.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Aleksey Ratnikov, 2015-12-14
@mahoho

You misinterpreted the function note. It says that the function strips the tags and returns their test content. You need to write a valid XPath expression that matches your condition. Use the XPath tutorial .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question