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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:59:23+00:00 2026-06-11T18:59:23+00:00

I`m having problem in getting an attribute from a xml object into JavaScript from

  • 0

I`m having problem in getting an attribute from a xml object into JavaScript from classic asp. The following is my code:

if(len>0){
<%for xx=0 to SNodes.length-1%>//asp code
{
 //Javascript code
var IXmlNode=xmlnewObj.createElement("I");
IXmlNode.setAttribute("a",document.getElementById('a'+xx).value);
IXmlNode.setAttribute("X","<%=SNodes.item(xx).getAttribute("PP")%>");
xmlnewObj.documentElement.appendChild(IXmlNode); 
<% next %>//asp code
}
}

Here SNodes has xml like:

<tag><tag1 a="iii" PP="asdasdf"/><tag1 a="aaa" PP="asdasdf"></tag>

Only this line is troubling me:

IXmlNode.setAttribute("X","<%=SNodes.item(xx).getAttribute("PP")%>");

What is wrong with this line?

  • 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-11T18:59:24+00:00Added an answer on June 11, 2026 at 6:59 pm

    What kind of javascript are you trying to output in the first place? As it stand now you’ll get something like this which would never work:

    if (len > 0) {
        {
            var IXmlNode = xmlnewObj.createElement("I");
                IXmlNode.setAttribute("a", document.getElementById('a' + xx).value);
            IXmlNode.setAttribute("X", "PP");
            xmlnewObj.documentElement.appendChild(IXmlNode);
        }
        {
            var IXmlNode = xmlnewObj.createElement("I");
            IXmlNode.setAttribute("a", document.getElementById('a' + xx).value);
            IXmlNode.setAttribute("X", "PP2");
            xmlnewObj.documentElement.appendChild(IXmlNode);
        }
    }
    

    It could work like this, but I still doubt that’s what you need:

    if (len > 0) {
        (function() {
            var IXmlNode = xmlnewObj.createElement("I");
                IXmlNode.setAttribute("a", document.getElementById('a' + xx).value);
            IXmlNode.setAttribute("X", "asdasdf");
            xmlnewObj.documentElement.appendChild(IXmlNode);
        })();
        (function() {
            var IXmlNode = xmlnewObj.createElement("I");
            IXmlNode.setAttribute("a", document.getElementById('a' + xx).value);
            IXmlNode.setAttribute("X","asdasdf");
            xmlnewObj.documentElement.appendChild(IXmlNode);
        })();
    }
    

    You’re best option is probably to turn it into a function and pass your asp variables into it:

    if(len>0){
        <%for xx=0 to SNodes.length-1%>//asp code
        {
            xmlAppender(<%=xx%>, <%=SNodes.item(xx).getAttribute("PP")%>);
        }
        <% next %>
     }
    
    var xmlAppender = function(i, childData) {
            var IXmlNode = xmlnewObj.createElement("I");
            IXmlNode.setAttribute("a", document.getElementById('a' + i).value);
            IXmlNode.setAttribute("X", childData);
            xmlnewObj.documentElement.appendChild(IXmlNode);
        };​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a problem getting a change event to register with the following code:
I'm having problem with getting ServiceStack [Authentication] attribute to work in ASP.Net MVC4 controller,
I am having problem getting this piece of code to run. The class is
I'm having a problem getting a simple ASP.NET webpage to display. The page contains
I am simply trying to retrieve an attribute from XML into my Perl program.
I am having problem getting my tooltip to work when using the jQuery load()
I am having a problem getting Twitter Bootstrap Carousel to begin looping automatically at
I'm having a problem getting XCode to deal with a particular file structure that
I am having a problem getting WinDbg to use the PDB files for my
I am having problem in getting reference of Ajax control extender using $find() or

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.