Advertisement
Guest User

Untitled

a guest
Aug 20th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. LOAD XML INFILE 'test_file.xml'
  2. INTO TABLE tbl_tutorials
  3. CHARACTER SET utf8
  4. ROWS IDENTIFIED BY '<row>'
  5. ;
  6.  
  7. CREATE TABLE IF NOT EXISTS tbl_tutorials(
  8. item_id INT(11) NOT NULL,
  9. title VARCHAR(100) NOT NULL,
  10. link VARCHAR(120) NOT NULL,
  11. description VARCHAR(400) NOT NULL,
  12. keywords VARCHAR (50) NOT NULL
  13. ) ;
  14.  
  15. <?xml version="1.0" encoding="UTF-8"?>
  16. <tbl_tutorials>
  17. <row>
  18. <item_id>1</item_id>
  19. <title>test title 1</title>
  20. <link>test link 1</link>
  21. <description>test description 1</description>
  22. <keywords>test keyword 1</keywords>
  23. </row>
  24. <row>
  25. <item_id>2</item_id>
  26. <title>test title 2</title>
  27. <link>test link 2</link>
  28. <description>test description 2</description>
  29. <keywords>test keyword 2</keywords>
  30. </row>
  31. <row>
  32. <item_id>3</item_id>
  33. <title>test title 3</title>
  34. <link>test link 3</link>
  35. <description>test description 3</description>
  36. <keywords>test keyword 3</keywords>
  37. </row>
  38.  
  39. SET @xmlFile = load_file('c:xamppmysqldatatest_foldertest_file.xml ');
  40. SELECT extractvalue(@xmlFile , '/tbl_tutorials/row/keywords') keywords;
  41.  
  42. ------------
  43. | keywords |
  44. ------------
  45. |NULL |
  46. ------------
  47.  
  48. ----------------
  49. | keywords |
  50. ----------------
  51. |test keyword 1|
  52. ----------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement