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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:21:09+00:00 2026-05-23T14:21:09+00:00

Trying to convert the following function to Coffeescript: var parse = function (elem) {

  • 0

Trying to convert the following function to Coffeescript:

    var parse = function (elem) {
        for each(var subelem in elem) {
            if (subelem.name() !== null ) {
                console.log(subelem.name());
                if (subelem.children().length() > 0) {
                    parse(subelem);
                }
            } else {
                console.log(subelem);
            }
        }
    };
   var xml = new XML(content);
   parse(xml);

It merely prints the element tags and any text to the console.

Tried using:

    parse = (elem) ->
        if elem.name()?                 
            console.log elem.name()
            if elem.children().length() > 0
                parse subelem for own elkey, subelem of elem
        else
            console.log elem

xml = new XML content
parse subelem for own elkey, subelem of xml

But it never seems to parse anything under the root xml node and ends up in an infinite recursion loop continuously printing out the root nodes tag until it blows up. Any ideas as to what I am doing wrong? Thanks.

  • 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-23T14:21:10+00:00Added an answer on May 23, 2026 at 2:21 pm

    Hmm. I tested this, and the issue seems to go away if you drop the own keyword, which adds a hasOwnProperty check. Somehow, the first child of each element seems to pass that check, while others fail it. I’m a bit mystified by this, but there’s your answer.

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

Sidebar

Related Questions

I am trying to convert the following JS snippet to CoffeeScript: $(document).ready(function(){ window.setTimeout(function(){ $('#flash').slideUp('slow',
Hello I'm trying to convert the following functions to a VBO based function for
I am trying to convert the following code to work with jquery: var req
I'm trying to convert the following function from ASP to PHP: Function InvalidParam(response) InvalidParam
I am trying to convert dips to pixels using the following function. I’ve tried
I am trying to convert text to wave file using following function. It works
Trying to convert the following but am having difficulty. Can anyone see where I'm
I'm trying to convert the following jquery to javascript syntax, but being not familiar
I am trying to convert the following SQL into a LINQ expression SELECT COUNT(ID)
I'm trying to convert the following list into a select list so it can

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.