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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T10:55:52+00:00 2026-05-30T10:55:52+00:00

Hey guys im having a problem trying to program out a set of logic.

  • 0

Hey guys im having a problem trying to program out a set of logic. I want to make a Go(the board game) problem. What i want my program to do is read in an xml file that represents a series of steps a person can make to complete the puzzle, or a even a dead end. So in the xml it would look something like

<Step x="4" y="5">
    <Response x="4" y="6" />
    <Step x="3" y="6" victory="true">
    </Step>
</Step>
<!-- This is a dead end -->
<Step x="4" y="4">
    <Response x="4" y="5" />

    <Step x="5" y="5" defeat="true"></Step>
    <Step x="6" y="4" defeat="true"></Step>
</Step>

My thought is to make a link list of sorts where my xml handler(im using SAX) uses the step class to store a step inside a step, but i cant conceptualize how i would run down the list like that. Does anyone have a clean way of doing something like this? *Note i need to run down each and every step, and if the step doesnt exist, call them wrong and make them try again, but im willing to change my xml to whatever it needs to be.

  • 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-30T10:55:54+00:00Added an answer on May 30, 2026 at 10:55 am

    I’m not entirely sure from your question whether you’re having problems with the XML or the Java representation. I’m assuming the latter.

    Representing successive play sequences in a game such as Go can be done using an n-ary tree. Each node in the tree represents a move, and all possible responses to a move are its children. This will match your XML representation.

    Here are two links that describe how to implement n-ary trees (taken from this SO question: k-ary Trees in Java )

    • http://sujitpal.blogspot.com/2006/05/java-data-structure-generic-tree.html
    • http://vivin.net/2010/01/30/generic-n-ary-tree-in-java/

    EDIT after your comment, here’s roughly how I would parse the document to create a tree (you’ll have to create your own Tree class still, I’m assuming basic tree methods here).

    class MyDocumentHandler {
        // The tree we are building
        private Tree tree;
        // The current element we are parsing
        private TreeNode current;
    
        public void startDocument() {
            // At the beginning of the document, create a new empty tree
            tree = new Tree();
            // The current node is the root
            current = tree;
        }
    
        public void startElement(String uri, String localName, String qName, Attributes attributes) {
            // Process the new element, read its attributes etc. to create the new TreeNode
            TreeNode child = new TreeNode();
            // Add the newly created node to the current element
            current.addChild(child);
    
            // The current element is now the child
            current = child;
        }
    
        public void endElement(String uri, String localName, String qName) {
            // When the current element ends, then return to its parent
            current = current.getParent();
        }
    }
    

    You can see how the successive calls to beginElement and endElement will create a tree that has the same structure as your document.

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

Sidebar

Related Questions

Hey guys im having a problem. Im trying to make a website with 3
Hey guys I'm having trouble looping through some XML. Im trying to capture the
Hey guys, I'm having a problem with IE7, my menu always drops down behind
Hey guys i want to execute my SQL statement but im having synatx trouble,
Hey guys I am having a lot of trouble trying to understand this and
Hey guys I am having trouble trying to convert my web app to support
hey guys, just having a bit of difficulty with a query, i'm trying to
Hey guys, I want to make a function loop over all elements that have
Hey guys, I'm having a problem handling my callback data in JQuery. The following
Hey guys I am having trouble with placing my buttons in my XML layout.

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.