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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:04:46+00:00 2026-05-16T06:04:46+00:00

Guys I’m new to xml in Java. I have the following task. I need

  • 0

Guys I’m new to xml in Java.

I have the following task. I need to parse some xml files (specificallyh xcb-proto [X11]) to generate the equivalent request protocol in java. There is already a well defined xsd and the respective xml for the protocol. What is the best and easiest approach/parser to solve this?

Example of existant xml content:

  <request name="SetScreenSaver" opcode="107">
    <pad bytes="1" />
    <field type="INT16" name="timeout" />
    <field type="INT16" name="interval" />
    <field type="CARD8" name="prefer_blanking" enum="Blanking" />
    <field type="CARD8" name="allow_exposures" enum="Exposures" />
  </request>

This will generate a Java DOM (?) Object. And them with this I need to generate the given code in Java. For this case is:

Desired output:

public void setScreenSaver(int timeout, int interval, int preferBlanking, int allowExposures) {
    RequestOutputStream o = outputStream;
    synchronized (o) {
        o.beginRequest(107, 0, 1); // Major Opcode , Minor Opcode, ReqLength
        o.writeInt16(timeout);
        o.writeInt16(interval);
        o.writeInt8(preferBlanking);
        o.writeInt8(allowExposures);
        o.send();
    }
}

It seems that XSOM is the one that gives the easier approach…

PS: I have never manipulated xml files in Java :3

  • 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-16T06:04:47+00:00Added an answer on May 16, 2026 at 6:04 am

    You should look into JAXB. It comes with a utility that will generate all your Java code using the .XSD file to determine the structure.

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

Sidebar

Related Questions

guys Following is the xml which i am trying to parse <?xml version=1.0 encoding=UTF-8?><Categories><category
guys i have a xml file which is like this: <Point TestFlag=0 id=1 name=Conversation
Guys i have a textview which i need it to be blinking please help
Guys can you suggest me any software who have some similarities with Microsoft's SQL
guys I want to start programing with C++. I have written some programs in
guys I am newbie to Hive and have some doubts in it. Normally we
guys. In our project, we need to add a new feature which is to
Guys, for some reason EL is not telling actions from properties. I have this
guys, I want to parse a xml in android which is got by HTTPPost
Guys I have problem to make a random matrix by considering some constraint and

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.