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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:14:23+00:00 2026-05-22T21:14:23+00:00

I trying to create an app that helps demonstrate different tools in AutoCAD with

  • 0

I trying to create an app that helps demonstrate different tools in AutoCAD with an animated gif slideshow, a list of associated commands and a description. The information loads upon clicking an image icon, a snippet is provided below.

<img class="toolicons" id="rectangle" />
<img class="toolicons" id="circle" />

Which affects the following:

<p id="toolName">Tool Name</p>
<p id="toolCmd">Tool Command 1, Tool Command 2</p>
<p id="toolDesc">Tool Description</p>
<img id="toolSlide" src="default-placeholder.gif" />

I want the information to be retrieved from an XML file since there are several tools that I might describe later and add to the XML, also wanting to avoid defining long string variables for the description.

<ACAD>
  <TOOL>
    <NAME>rectangle</NAME>
    <CMD> 
      <CMD_01>REC</CMD_01>
      <CMD_02>RECTANG</CMD_02>
      <CMD_03>RECTANG</CMD_03>
    </CMD>
    <DESCRIPTION>Draws a rectangle</DESCRIPTION>
    <SLIDESHOW>rectangle.gif</SLIDESHOW>
  </TOOL>

  <TOOL>
    <NAME>circle</NAME>
    <CMD> 
      <CMD_01>C</CMD_01>
      <CMD_02>CIRCLE</CMD_02>
    </CMD>
    <DESCRIPTION>Draws a circle</DESCRIPTION>
    <SLIDESHOW>circle.gif</SLIDESHOW>
  </TOOL>
</ACAD>

I’m trying to use jQuery to do this. I shouldn’t be using .each() since I only want to retrieve one entity, not parse all of them.

I’ve attempted to look this up but I can’t find anything demonstrating a comparison between HTML id attribute and XML data, then taking just the data.

$(function(){
    $(".toolicons").click(function(){ 
      $.ajax({
        type: "GET",
        url: "acad.xml",
        dataType: "xml",
        success: function(xml) {
          $(xml).find('TOOL').each(function(){
            var tName = $(this).find('NAME').text();    
            var tDesc = $(this).find('DESCRIPTION').text();
            $(this).find('CMD').each(function(){
              var tCmd1 = $(this).find('CMD_01').text();
              var tCmd2 = $(this).find('CMD_02').text();
              var tCmd3 = $(this).find('CMD_03').text();
            });
          });
        }
        // change html in p elements from xml data
      });
    });
});
  • 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-22T21:14:24+00:00Added an answer on May 22, 2026 at 9:14 pm

    You can use :contains() selector

    Code example (without error checking neither validation):

    jQuery(document).ready(function()
    {
        jQuery(".toolicons").click(function(e)
        {
            e.preventDefault();
    
            var id = jQuery(this).attr('id');
    
            jQuery.ajax({
                type: "GET",
                url: "acad.xml",
                dataType: "xml",
                success: function(xml) {
                    var jqToolName = jQuery(xml).find('NAME:contains("' + id + '")');
                    var jqTool = jqToolName.parent();
                    var tName = jqTool.find('NAME').text();
                    var tDesc = jqTool.find('DESCRIPTION').text();
    
                    // console.log(tName, tDesc);
                }
            });
        });
    });
    

    Anyway, i will program it in a different way:

    • load the XML only once, on first use or after page/DOM load,
    • parse the XML data and store it in a javascript structure, with the tool name as key
    • when an image is clicked, gets its ID and look for the tool information in the javascript structure

    Regards

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

Sidebar

Related Questions

I am trying to create a simple app that displays a list of items
I'm trying to create a WinForms app that takes a screenshot on a set
Trying to create my first iPhone app that would play back audio. When I
I'm trying to create an app for Android that simply sends a command to
I'm trying to create a C# form app that will allow me to use
I'm trying to create a rails web app that does not use ActiveRecord framework
I'm trying to create a simple Java app that uses JNI to call some
what i'm trying to do this this. Simply create a C# windows app that
Im trying to create a listing app that is core data backed.The first page
I am trying to create an app with horizontal scrolling, so that one would

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.