DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Unveiling the Clever Way: Converting XML to Relational Data
  • Go Application Vulnerability Cheatsheet
  • The X-Factor: RAML With XML Format
  • How To Persist and Query Data With SQLite in Flutter App Development

Trending

  • Beyond Manual Mapping: AI-Orchestrated Governance for Hybrid Cloud
  • Build a GitHub Contribution City With Java and Quarkus
  • Every Generation Fears the Machine. Here Is How the AI Job Panic Usually Ends
  • Designing Memory Architecture for Stateful AI Agents: Short-Term Context and Long-Term Persistence

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  1. DZone
  2. Coding
  3. Languages
  4. Importing XML Data Into A SQLite Table

Importing XML Data Into A SQLite Table

By 
Jonnie Spratley
·
Sep. 21, 08 · Code Snippet
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
16.0K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in
For inserting into a SQLite table, use the code as follows:



//DB Connection
private var dbconn:SQLConnection;
//Query Statement
private var sqlQuery:SQLStatement;		
//Create Table Statement
private var sqlCreateTable:SQLStatement;
//Insert Statement
private var sqlInsert:SQLStatement;
//Import Statement
private var sqlImport:SQLStatement;

			 
 /**
  * This is for importing xml data to a SQLite table 
  * @param node xml node
  * @param user the user whos data this is
  * 
  */			 
 public function importPostXML( node:XMLNode, user:User ):void
 {
	var query:String = "INSERT INTO posts (" + 
									"post_url," + 
									"post_hash," + 
									"post_desc," + 
									"post_tags," + 
									"post_time," + 
									"post_extended," + 
									"post_shared," + 
									"post_replace," + 
									"post_user)" + 
							"VALUES ( " + 
									":post_url," + 
									":post_hash," + 
									":post_desc," + 
									":post_tags," + 
									":post_time," + 
									":post_extended," + 
									":post_shared," + 
									":post_replace," +												
									":post_user)";
	sqlImport = new SQLStatement();
	sqlImport.sqlConnection = dbconn;
	sqlImport.addEventListener( SQLEvent.RESULT, onSQLSave );
	sqlImport.addEventListener( SQLErrorEvent.ERROR, onSQLError );
	sqlImport.text = query;
	
	sqlImport.parameters[":post_url"] = node.attributes.href;
	sqlImport.parameters[":post_hash"] = node.attributes.hash;
	sqlImport.parameters[":post_desc"] = node.attributes.description;
	sqlImport.parameters[":post_tags"] = node.attributes.tag;
	sqlImport.parameters[":post_time"] = node.attributes.time;
	sqlImport.parameters[":post_extended"] = node.attributes.extended;
	sqlImport.parameters[":post_shared"] = node.attributes.shared;
	sqlImport.parameters[":post_replace"] = node.attributes.replace;
	sqlImport.parameters[":post_user"] = user.user_name;
	
	sqlImport.execute();
	
	trace( "Importing XML to SQLite Database" );				
 }

XML Data (computing) SQLite

Opinions expressed by DZone contributors are their own.

Related

  • Unveiling the Clever Way: Converting XML to Relational Data
  • Go Application Vulnerability Cheatsheet
  • The X-Factor: RAML With XML Format
  • How To Persist and Query Data With SQLite in Flutter App Development

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook