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

  • Home
  • SEARCH
  • 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 6104403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:50:17+00:00 2026-05-23T13:50:17+00:00

I am trying to write a javascript function to parse a bit of the

  • 0

I am trying to write a javascript function to parse a bit of the DOM tree and return a part of it to further parse. Despite stepping through the function which seems to be working fine, the return of the function shows as undefined to the calling statement. Is there a way to fix this?

from = entityfromid($(value)[0].getElementsByTagName("O1")[0].childNodes[0].childNodes[0].nodeValue).getElementsByTagName("Name")[0].childNodes[0].nodeValue;

function entityfromid(id) {
$($(xmlDoc)[0].getElementsByTagName("Entities")[0].childNodes).each(function (index, value) {
    if(value.getElementsByTagName('Id')[0].childNodes[0].nodeValue == id) {
        return value;
    }
});
}
  • 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-23T13:50:18+00:00Added an answer on May 23, 2026 at 1:50 pm

    You need to take the return statement out of the .each(), and instead return from your entityfromid function.

    function entityfromid(id) {
    
        var ret_value;
    
        $($(xmlDoc)[0].getElementsByTagName("Entities")[0].childNodes).each(function (index, value) {
            if(value.getElementsByTagName('Id')[0].childNodes[0].nodeValue == id) {
                ret_value = value;
                return false;
            }
        });
        return ret_value;
    }
    

    Here, when your result is found, it will set the value of the ret_value variable, and do a return false, which breaks the loop.

    Then the ret_value is used for the return from your function.

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

Sidebar

Related Questions

I am trying to write a JavaScript function that will return its first argument(function)
I'm trying to write a javascript function that adds some DOM nodes to the
I am trying to write a javascript function which is called input() (performing input
I am trying to write a javascript function with an if statement that will
I am trying to write DOM viewer on JavaScript. How I can get all
I'm trying to write a Javascript function to edit content from clipboard before pasting.
I am trying to write a javascript function to resize an image based on
I am trying to write a JavaScript function to get the current browser width.
I am trying to write some javascript which will check the checkboxes within a
I am new to programming and trying to write a javascript function to set

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.