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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:50:30+00:00 2026-05-27T19:50:30+00:00

I am trying to pull an xml node’s value by referencing the value of

  • 0

I am trying to pull an xml node’s value by referencing the value of another node.

Here is an snippet of one of my nodes

<document>
 <row>
  <DISTRICT>100</DISTRICT>
  <BIOS>BROWN</BIOS>
  <AREA_KM>3663.158164</AREA_KM>
  <AREA_MI>1414.347616</AREA_MI>
  <NAME>100</NAME>
  <REG>1</REG>
  <ACRES>905182</ACRES>
  <EMU_Name>Purcell</EMU_Name>
  <Shape_Leng>299746.4938</Shape_Leng>
  <Shape_Area>3663158164</Shape_Area>
  <LegalDesc>Northeast of District 151</LegalDesc>
 </row>
</document>

I’d like to fill in some HTML with value from the LegalDesc field based on the # in the DISTRICT field.

for example, I’d like to display the LegalDesc for DISTRICT==100. tempDist value comes from a form with a drop down

Something like this?

function dropDownAction(){
    var tempDist=document.HDForm.HuntingDistrict.value;
    var tempDesc=xmlDoc.getElementsByTagName("DISTRICT")[tempDist].getAttribute("LegalDesc");
    document.getElementById("field2").innerHTML=tempDesc;
}

thank 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-05-27T19:50:31+00:00Added an answer on May 27, 2026 at 7:50 pm

    Personally, I would load all the rows into an array (using district as a key); then simply get the description from the array:

    var xmlDoc = // load doc
    var elementsToLoopThru=xmlDoc.getElementsByTagName("row");
    var rowArray = new Array();
    
    // go thru all the rows
    for (var i = 0;i<elementsToLoopThru.length;i++){
        var district = "";
        var description = "No Description";
        var currRowChildren = elementsToLoopThru[i].childNodes;
    
        // go thru all the elements of a row and get the district and description
        for (var j = 0;j < currRowChildren.length; j++){
            if (currRowChildren[j].nodeName == "DISTRICT"){
                district = currRowChildren[j].childNodes[0].nodeValue;
            }
            else if (currRowChildren[j].nodeName == "LegalDesc"){
                description = currRowChildren[j].childNodes[0].nodeValue;
            }
        }
    
        // if district and description found, enter them as key value pair into array
        if (district != ""){
            rowArray[district] = description;
            alert(district + ": " + description); // DELETE ME
        }
    }
    

    Double check my code; I think it should work, but I am pretty rusty navigating XML

    Then when you need to get value, simply access rowArray[NAME_OF_DISTRICT]

    This should work if:

    • Districts are unique
    • and it DOESN’T MATTER IF DISTRICTS ARE ORDERED

    here is jsfiddle: http://jsfiddle.net/RwE9s/15/

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

Sidebar

Related Questions

I'm trying to pull in an src value from an XML document, and in
I'm trying to create a site that will pull xml nodes into html using
I'm trying to pull data using a SqlDataReader, one column of which is in
I am trying to pull information from another site. When I try and do
im having some difficulty trying to pull out a specific value from a cookie.
Trying to pull a value from the sunrise element from [yweather:astronomy] in the Yahoo
Here is the basic XSL. I am trying to pull out the element q_DECISION_NUMBER
I have an xml document that I am trying to style with xsl. The
I'm using javascript to pull data returned from an XML document. Inside this XML
i'm trying to pull out a node from a csproj file that looks like

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.