1

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>';
how can i insert the name into the database? (this is the sample xml and i have xml with more than 9000 rows).

1
  • I got the answer, added code : $doc = new DOMDocument(); $doc->load($xml_file_name); $doc->save ( $xml_file_name, LIBXML_NOEMPTYTAG ); // code to remove empty records or self closed tag Commented Nov 15, 2013 at 10:30

1 Answer 1

1

I got the answer
$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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.