XPath support for XML data in MySQL _ MySQL

Source: Internet
Author: User
XML data in MySQL supports bitsCN.com.

Today, I want to introduce you to XPath, which is the language for navigation and querying XML documents. We start with a function.

 UpdateXML () function

We have spent a lot of time introducing the ExtractValue () function, but have not introduced other XML functions of MySQL, such as UpdateXML (), because we previously mainly imported the data in the XML document into the MySQL database, UpdateXML () is a function that uses different XML tags to match and replace XML blocks.

ExtractValue () has two string parameters: an XML tag and an XPath expression.

ExtractValue (xml_frag, xpath_expr)

It returns the first text node that matches the XPath expression. Suppose you want to "To" And save the result to a variable. The following is how to use the UpdateXML () function to achieve this goal:

Mysql> SELECT @ new_xml_node: = UpdateXML ( ,
-> // City,
-> )
-> AS xml_node;
+ ----------------------------------------- +
| Xml_node |
+ ----------------------------------------- +
| |
+ ----------------------------------------- +
1 row in set (0.03 sec)

Mysql> SELECT @ new_xml_node;
+ ----------------------------------------- +
| @ New_xml_node |
+ ----------------------------------------- +
| |
+ ----------------------------------------- +
1 row in set (0.00 sec)

If no text node matching the expression is found, the original XML string is returned.

Mysql> SELECT @ new_bitsCN.com

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.