Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6701213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:54:25+00:00 2026-05-26T06:54:25+00:00

I am using ColdFusion (openBlueDragon) to insert the data from a large (200MB) xml

  • 0

I am using ColdFusion (openBlueDragon) to insert the data from a large (200MB) xml file into a database without having to load the entire file into memory which is how I traditionally would do it. I did find a VERY SIMILAR QUESTION here: Looping over a large XML file that seems to be the answer I am looking for.

However, I’m not skilled enough in java to understand and adapt the code to my needs. I found no way to respond to the expert (@orangepips) who posted the code or else I would not have posted such a similar question.

My xml file looks like this:

 <allItems>
    <item>
        <subject>The subject text</subject>
        <date>2007-05-21 04:03:00</date>
        <content>text content often contains many paragraphs of text</content>
        <author>JPass78</author> 
    </item>
</allItems>

This is the code, courtesy orangepips, that I’m trying to adapt for my purpose. I’ve modified it a bit to include my own field names:

<cfset fis = createObject("java", "java.io.FileInputStream").init(
"#getDirectoryFromPath(getCurrentTemplatePath())#/file.xml")>
<cfset bis = createObject("java", "java.io.BufferedInputStream").init(fis)>
<cfset XMLInputFactory = createObject("java", "javax.xml.stream.XMLInputFactory").newInstance()>
<cfset reader = XMLInputFactory.createXMLStreamReader(bis)>

<cfloop condition="#reader.hasNext()#">
<cfset event = reader.next()>
<cfif event EQ reader.START_ELEMENT>
    <cfswitch expression="#reader.getLocalName()#">
        <cfcase value="allItems">
            <!--- root node, do nothing --->
        </cfcase>
        <cfcase value="item">
            <!--- set values used later on for inserts, selects, updates --->
        </cfcase>
        <cfcase value="subject">
            <!--- some selects and insert --->
        </cfcase>
        <cfcase value="contentdate">
            <!--- insert or update --->
        </cfcase>
        <cfcase value="content">
        </cfcase>
        <cfcase value="author">
         </cfcase>  
    </cfswitch>
</cfif>
</cfloop>
<cfset reader.close()>

I have a single table and I am trying to figure out how do I access the values from each XML element so I may insert it one row at a time? like this: INSERT INTO content (subject,contentdate, content, author)
VALUES (“The subject text”, 2007-5-21 04:03:00, “text content here”,”JPass78″);

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T06:54:26+00:00Added an answer on May 26, 2026 at 6:54 am

    Instead of using COLDFUSION to import large XML files into a MYSQL database, use the MYSQL command “LOAD XML INFILE”.

    Here’s the simple, light and fast code that worked for me:

    LOAD XML INFILE 'pathtofile/file.xml' INTO TABLE table_name ROWS IDENTIFIED BY '<item>';

    My xml file uses the same exact field names as my database table. ROWS IDENTIFIED BY tells the command that the field names in my xml file will correspond to the database fields in my table and they will be found in between the <item></item> tags.

    FYI, <item> is my own naming format. Your file will likely have another tag name that relates to the data you’re working with. For example, if your xml file is for employee data, you might instead use <employee>

    Available in MYSQL5.5 – Reference for LOAD XML INFILE can be found at:
    http://dev.mysql.com/doc/refman/5.5/en/load-xml.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to load a CSV file into an array using ColdFusion (version
I'm using ColdFusion to return a result set from a SQL database and turn
I'm using coldfusion 9 and I'm trying to grab a file from an ftp
I'm using coldfusion to insert the contents of a struct (key-value pairs) into a
I'm working on a Fusebox application using Coldfusion, and there is a fusebox.xml file
How to print all the result without using Results.columnname in ColdFusion for ex:- I
Using ColdFusion and Microsoft SQL we are exporting data to an Excel Spreadsheet using
I am using Coldfusion to view images stored in the file system and I
I am using ColdFusion 9.1.2 We are using a CFC to save some data
I am using ColdFusion 9.0.1 and SQL Server 2005. The column in my database

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.