AS3 Import XML To SQLite


/ Published in: Other
Save to your folder(s)



Copy this code and paste it in your HTML
  1. /**
  2. * This is for importing xml data to a SQLite table
  3. * @param node xml node
  4. * @param user the user whos data this is
  5. *
  6. */
  7. public function importPostXML( node:XMLNode, dUser:UserVO ):void
  8. {
  9. var query:String = "INSERT INTO posts (" +
  10. "post_url," +
  11. "post_title," +
  12. "post_description," +
  13. "post_tags," +
  14. "post_shared," +
  15. "post_timestamp," +
  16. "post_replace," +
  17. "delicious_user )" +
  18. "VALUES ( " +
  19. ":post_url," +
  20. ":post_title," +
  21. ":post_description," +
  22. ":post_tags," +
  23. ":post_shared," +
  24. ":post_timestamp," +
  25. ":post_replace," +
  26. ":delicious_user)";
  27.  
  28. sqlImport = new SQLStatement();
  29.  
  30. sqlImport.sqlConnection = dbconn;
  31. sqlImport.addEventListener( SQLEvent.RESULT, onSQLSave );
  32. sqlImport.addEventListener( SQLErrorEvent.ERROR, onSQLError );
  33. sqlImport.text = query;
  34.  
  35. sqlImport.parameters[":post_url"] = node.attributes.href;
  36. sqlImport.parameters[":post_title"] = node.attributes.description;
  37. sqlImport.parameters[":post_description"] = node.attributes.extended;
  38. sqlImport.parameters[":post_tags"] = node.attributes.tag;
  39. sqlImport.parameters[":post_shared"] = node.attributes.shared;
  40. sqlImport.parameters[":post_timestamp"] = node.attributes.time;
  41. sqlImport.parameters[":post_replace"] = "no";
  42. sqlImport.parameters[":delicious_user"] = dUser.username;
  43.  
  44. sqlImport.execute();
  45.  
  46. trace( "Importing XML to SQLite Database" );
  47. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.