A Bogus
A Bogus

Reputation: 3930

Using extractvalue to get XML attribute

Using MySQl, I am trying to use extractvalue to find the value of an XML node's attribute. What should the extractvalue command look like?

Example -

SET @xml = '<a>
              <b thing="09876"></b>
            </a>'

SELECT extractvalue(@xml,'???')

What would the command look like to display the value of 'thing'?

Upvotes: 1

Views: 970

Answers (1)

Gurwinder Singh
Gurwinder Singh

Reputation: 39507

Add attribute::<attributename> to the XPath:

SELECT extractvalue(@xml,'/a/b/attribute::thing')

Demo

Upvotes: 2

Related Questions