Sunday, January 23, 2022

[FIXED] how to execute XML data in to phpmyadmin Database

Issue

Hear is my XML data set. I want to execute this file format in to phpMyAdmin database.

<?xml version="1.0" standalone="yes" ?>
<NewDataSet>
    <company>
        <COM_CODE>Test Data</COM_CODE>
        <COM_NAME>Test Data</COM_NAME>
        <COM_ADDRESS>Test Data</COM_ADDRESS>
    </company>
</NewDataSet>

Solution

There are two functions available for providing basic XPath 1.0 (XML Path Language, version 1.0) in MySQL.Which are

ExtractValue():Extracts a value from an XML string using XPath notation

UpdateXML():Return replaced XML fragment

Simplest example for executing XML is:

SELECT ExtractValue('<NewDataSet><company><COM_CODE>Test Data</COM_CODE></company></NewDataSet>', '/NewDataSet/company/COM_CODE');//returns Test Data which is value inside <COM_CODE></COM_CODE>

For more see Mysql Docs MYSQL XML Functions



Answered By - Hikmat Sijapati

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.