I am trying to insert data from xml to mysql database using LOAD XML LOCAL INFILE in php but it inserted blank values for self closed xml tags like <Password />
here is the xml code
<?xml version="1.0" encoding="UTF-8" ?>
<Users>
<User>
<Password />
<Name>name1</Name>
</User>
</Users>
php mysql code:
LOAD XML LOCAL FILE 'users.xml' INTO TABLE data users ROWS IDENTIFIED BY '<User>';
我得到了答案
$doc = new DOMDocument();
$doc->load($xml_file_name); //load xml file $xml_file_name='xml file name'
$doc->save ( $xml_file_name, LIBXML_NOEMPTYTAG ); // code to remove empty records or self closed tag
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.