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 170903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T12:53:32+00:00 2026-05-11T12:53:32+00:00

I need to process XML documents of varying formats into records in a MySQL

  • 0

I need to process XML documents of varying formats into records in a MySQL database on a daily basis. The data I need from each XML document is interspersed with a good deal of data I don’t need, and each document’s node names are different. For example:

source #1:

<object id='1'>     <title>URL 1</title>     <url>http://www.one.com</url>     <frequency interval='60' />     <uselessdata>blah</uselessdata> </object> <object id='2'>     <title>URL 2</title>     <url>http://www.two.com</url>     <frequency interval='60' />     <uselessdata>blah</uselessdata> </object> 

source #2:

<object'>     <objectid>1</objectid>     <thetitle>URL 1</thetitle>     <link>http://www.one.com</link>     <frequency interval='60' />    <moreuselessdata>blah</moreuselessdata> </object> <object'>     <objectid>2</objectid>     <thetitle>URL 2</thetitle>     <link>http://www.two.com</link>     <frequency interval='60' />     <moreuselessdata>blah</moreuselessdata> </object> 

…where I need the object’s ID, interval, and URL.

My ideas for approaches are:

1.) Having a separate function to parse each XML document and iteratively create the SQL query from within that function

2.) Having a separate function parse each document and iteratively add each object to my own object class, and have the SQL work done by a class method

3.) Using XSLT to convert all the documents into a common XML format and then writing a parser for that document.

The XML documents themselves aren’t all that large, as most will be under 1MB. I don’t anticipate their structure changing often (if ever), but there is a strong possibility I will need to add and remove further sources as time goes on. I’m open to all ideas.

Also, sorry if the XML samples above are mangled… they’re not terribly important, just a rough idea to show that the node names in each document are different.

  • 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. 2026-05-11T12:53:32+00:00Added an answer on May 11, 2026 at 12:53 pm

    Using XSLT is an overkill. I like approach (2), it makes a lot of sense.

    Using Python I’d try to make a class for every document type. The class would inherit from dict and on its __init__ parse the given document and populate itself with the ‘id’, ‘interval’ and ‘url’.

    Then the code in main would be really trivial, just instantiate instances of those classes (which are also dicts) with the appropriate documents and then pass them off as normal dicts.

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

Sidebar

Related Questions

I need to process the incoming predefined ASN format data(coming from verity of clients
I have a quite big XML output from an application. I need to process
I need to process an XML DOM, preferably with JDOM, where I can do
I have a chunk of xml data that's coming out of a database that
Hi I'm using pugixml to process xml documents. I iterate through nodes using this
I want to develop a XBRL converter which can convert documents/reports from .doc/.xml/.txt/.csv to
I need an automated process for creating docx files from xhtml source. The xhtml
I'm working on some PHP to create XML from a database using the DOM
I have a System.XML.Schema.XmlSchema loaded into memory and an XML instance data of element
I am helping a non-profit organization organize their existing data into a database. The

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.