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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:07:20+00:00 2026-05-18T00:07:20+00:00

I need to insert data from my parsed XML file to mySQL table. Problem

  • 0

I need to insert data from my parsed XML file to mySQL table. Problem is that I have few attributes and don’t know how to insert them in one row. I tried with updateString but it writes only last attribute.

Here is example from XML file:

<Tr rn=\"999999999999999\" vr=\"T\" sSpre=\"S\" reg=\"P\" dSpre=\"2010-09-30\" dOdprt=\"2000-01-01\" iban=\"SI56\" eno=\"R\" vir=\"R\" maticnaPps=\"00000000\"><Imetnik davcna=\"0000000\" matSub=\"0000000\" drz=\"705\"><PopolnoIme>xxx</PopolnoIme><KratkoIme>xxx</KratkoIme><Naslov sifTipNaslova=\"01\" sifObcina=\"039\" sifPosta=\"1303\" sifUlica=\"0000\" sifNaselje=\"059\" stHisna=\"027\" sifHsmid=\"11694551\"><Obcina>xxx</Obcina><Posta>xxx</Posta><Ulica>xxx</Ulica><Naselje>xxx</Naselje></Naslov></Imetnik></Tr>

This is scratch from my java program that I used for writing in mySQL table.

if (myWorkLine.substring(0,4).equals(Tr)) {

    uprs.afterLast();
    uprs.moveToInsertRow();

if (myWorkLine.contains(Tr)) {
    myWorkLine = myWorkLine.substring(myWorkLine.indexOf(Tr)+4);
    while (!myWorkLine.substring(0,1).equals("<")) {
        myTag = myWorkLine.substring(0,myWorkLine.indexOf("="));
        myWorkLine = myWorkLine.substring(myWorkLine.indexOf("=")+2);
        myValue = myWorkLine.substring(0,myWorkLine.indexOf("\""));
        myWorkLine = myWorkLine.substring(myWorkLine.indexOf("\"")+2);
        uprs.updateString("Tr",myTag + " " + myValue);
        if (myWorkLine.substring(0,myWorkLine.indexOf("\">")).indexOf(">") > 0)
            break;
    }
}

So once again, I need that in MySQL table column Tr contains attributes rn value, vr value, sSpre value,…

Thanks in advance.

P.S.: Please don’t ask why I’m parsing XML file by this method, I had to do it that way. 🙂

  • 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-18T00:07:20+00:00Added an answer on May 18, 2026 at 12:07 am

    Your code will repeatedly replace the “Tr” column with your concatenation of tag + ” ” + value so it’ll only be the last one that goes in. Don’t you perhaps want the different tags to go in different columns? Or maybe you need to continue concatenating and only call updateString at the end.

    Could you post the desired table row for the given XML? That should help in determining what you are trying to achieve.

    For example, if you just want to append them:

    StringBuffer tr = new StringBuffer();
    while (!myWorkLine.substring(0,1).equals("<")) {
        myTag = myWorkLine.substring(0,myWorkLine.indexOf("="));
        myWorkLine = myWorkLine.substring(myWorkLine.indexOf("=")+2);
        myValue = myWorkLine.substring(0,myWorkLine.indexOf("\""));
        myWorkLine = myWorkLine.substring(myWorkLine.indexOf("\"")+2);
        tr.append(myTag + " " + myValue).append(",");
        if (myWorkLine.substring(0,myWorkLine.indexOf("\">")).indexOf(">") > 0)
            break;
    }
    if (tr.length() > 0) {
        tr.deleteCharAt(tr.length()-1);  // get rid of last comma
    }
    uprs.updateString("Tr",tr.toString());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a binary file that I need to insert a header at the
In postgresql, I need to insert data to, say table B from sql query
now i need to insert some data from the sqlserver into a word,i know
Basically I need to insert a bunch of data to an Excel file. Creating
I need to create an SQL query to insert some data into a table
I need to insert records into a table that has no primary key using
I am making a CSS file for an XML document. I need to insert
I need to insert about 1.8 million rows from a CSV file into a
My application is fetching a data dynamically from MYSQL and displaying. The Problem is
I have a script that follows that is supposed to collect data from a

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.