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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:27:43+00:00 2026-06-13T23:27:43+00:00

I’m looking for something to easily create an Object to access a large XML

  • 0

I’m looking for something to easily create an Object to access a large XML file.

The XML file looks like this:

<?xml version="1.0" encoding="WINDOWS-1252"?>
    <vzg:vzg erstellt_von="##" erstellt_am="###" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:vzg="###" xsi:schemaLocation="###">
      <auswahl sicht="B" basisfplp_id="0" basisve_id="0">
        <fplp vzg_id="0" periode="2012/2013"/>
        <version vzg_id="###" name="###"/>
        <strecke name="11801">
          <von baukms_nr="###" km="#.#"/>
          <bis baukms_nr="###" km="#.#"/>
        </strecke>
        <bst vzg_id="#" name="#" kurzbez="##" bez="####" kritart="#"/>
        <bst vzg_id="#" name="#" kurzbez="##" bez="####" kritart="#"/>
        <bst vzg_id="#" name="#" kurzbez="##" bez="####" kritart="#"/>
        <bst vzg_id="#" name="#" kurzbez="##" bez="####" kritart="#"/>
        <bst vzg_id="#" name="#" kurzbez="##" bez="####" kritart="#"/>
        ...

I want an Object to calculate with some of the XML Attributes.

Like:

List vzg_id=vzg.auswahl.bst;

int res=vzg_id.get(3) * vzg.auswahl.strecke.von.baukms_nr;

Since the XML has about 16000 Lines it’s difficult to create a class for every XMLElement.

What I’ve done now:

MainClass

import java.util.ArrayList;
import java.util.List;

import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

import java.io.File;

import javax.xml.bind.JAXB;

public class Main
{
    public static void main(String[] args)
    {
        VZG vzg = JAXB.unmarshal(new File("./XMLVZG.xml"), VZG.class);


        System.out.println(vzg.erstellt_am+ " "+vzg.erstellt_von+"\n"+vzg.aw.sicht);
    }
}

Class VZG

import java.util.ArrayList;
import java.util.List;

import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement
public class VZG
{
    @XmlElement(name="auswahl")
    AuswahlSicht aw;
    @XmlAttribute(name="erstellt_von")
    String erstellt_von;
    @XmlAttribute(name="erstellt_am")
    String erstellt_am;
    @XmlAttribute(name="xsi")
    String xmlns_xsi;   
}

Class Auswahl

import java.util.List;

import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name="auswahl")
public class AuswahlSicht
{
    @XmlAttribute(name="basisfplp_id")
    int basisfplp_id;
    @XmlAttribute(name="basisve_id")
    int basisve_id;
    @XmlAttribute(name="sicht")
    String sicht;

}

So I’m now able to get the Attributes of the Root and the Cild, but I have still about 1000 childs with Attributes left and I’m looking for an automated way to parse the XML to get an object.
Simple Description:
XML File

<root>
 <child>
   <Subchild id="1"/>
    <subsubchild id=2/>
    <subsubchild id=33/>
 </child>
</root>

The object should then be like this:

List subsubchilds = root.child.subchild.subsubchild;
int id_one=subsubchilds.get(0);

Thanks in advance

  • 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-06-13T23:27:44+00:00Added an answer on June 13, 2026 at 11:27 pm

    It is rarely a good idea to write JAXB classes by hand for existing XML. JDK has special command line tool to generate these classes for you (xjc) from XML schema. If schema is not available you could try to generate schema from XML (various tools can do that – for example XMLSpy) and then generate classes using xjc.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
In my XML file chapters tag has more chapter tag.i need to display chapters
I am trying to render a haml file in a javascript response like so:
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I'm parsing an XML file, the creators of it stuck in a bunch social
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have a jquery bug and I've been looking for hours now, I can't

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.