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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:56:44+00:00 2026-06-13T09:56:44+00:00

I’m overwhelmed with attempting to design a solution for this problem – it’s a

  • 0

I’m overwhelmed with attempting to design a solution for this problem – it’s a by-product of inexperience.

My goal is to read an XML input file, store the information from the XML and populate two combo boxes with data from the XML. The content of the second combo box will change based on the selection in the first.

Given this XML structure:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Category xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Node>
    <ID>Unique string</ID>
    <Name>Unique string</Name>
    <Code>Generic string<Code>
    <Kind>Generic string</Kind>
    <Frame>Generic string</Frame>
            ...
</Node>
    ...
</Category>

First combo box:
Must contain only the unique values found in the the Kind section.

Second combo box:
Contains ALL of the Name entries from every Node whose Kind equals the Kind selected in the first combo box.

Regarding the XML source:
It is externally maintained and generated.
The values in the ID section are always going to be unique.
The values in the Name section are always going to be unique.
The schema will (supposedly) never change.
New unique values may appear in the Kind section in the future.

My proposed solution:
Create a class XMLNode to represent a Node from the XML source.
Members of class XMLNode correspond to the tags in each Node.
Loop through all the Nodes and create an XMLNode for each one.
While looping through nodes:
Add XMLNode objects in a hash map, with Keys = XMLNode.ID and vals = the XMLNode.
Create an array of unique Kinds.

Populate combo box one from the array of Kind entries.
Populate combo box two from the Name data for each .

Is this an appropriate approach, or have I overlooked a better/easier/more elegant solution?
If I’m on the right track, are there any obvious flaws to my proposed solution?

  • 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-13T09:56:45+00:00Added an answer on June 13, 2026 at 9:56 am

    I ended up with a class NodeImporter and a class Node. Node represents a node, NodeImporter parses the XML. In the NodeImporter, the XML source is parsed and represented as a HashMap of HashMaps. The outer HashMap (Key,Value) is (Kind,(HashMap(Key,Value)). The inner HashMap (Key,Value) is (UinqueID,Node) for a final result of (Kind,(UniqueID,Node)). I call the final result “filteredMap”. All of NodeImporter’s fields and methods are private, except for the constructor, and a getter for filteredMap.
    The class that needs the data to build the combo boxes gets filteredMap from an instance of NodeImporter. It can then get the keys of the outer HashMap to build the first ComboBoxModel. It can just as easily get the inner HashMap to be used as the HashMap for the second combo box.

    pseudo code for setup:

    Class NodeImporter built with class members:

    arrayList(String) uniqueKinds = null  
    arrayList(Node) allNodes  = null  
    HashMap(String, HashMap(String,Node))) filteredNodes = null  
    

    Class NodeImporter constructor:

    open XML  
    while xml source has next  
      {  
      add next node to allNodes, key = node.uniqueId, Val = node  
      if next node.kind not in uniqueKinds, add node.kind to uniqueKinds  
      }
    
    
    
    ClassNodeImporter method makeFilteredeMap:  
    
        private boolean makeFilteredeMap() {
            if (uniqueKinds.isEmpty()) {
                return false;
            } else {
                for (String k : uniqueKinds) {
                    HashMap<String, Node> aMap = new HashMap<String, Node>();
                    for (Node n : allNodes) {
                        if (n.getKind().equals(k)) {
                            aMap.put(n.getCode(), n);
                        }
                    }
                    filteredNodes.put(k, aMap);
                }
                return true;
            }
        }
    
    • 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
In my XML file chapters tag has more chapter tag.i need to display chapters
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
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,

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.