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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:32:17+00:00 2026-05-22T20:32:17+00:00

all! I’m having some issues accessing an XML node’s properties using Javascript. The XML

  • 0

all! I’m having some issues accessing an XML node’s properties using Javascript.

The XML node in particular looks like the following:

<List DocTemplateUrl="" DefaultViewUrl="/Lists/Announcements/AllItems.aspx" MobileDefaultViewUrl="" ID="{blahblahblahblah}" ... />

The node itself has no “data” contained within its tags; all the data it holds are actual modifiers of the List tag.

Javascript’s XML DOM reference provides little information on how to access modifiers of node tags; all the methods and properties in the DOM reference refer to child nodes and how to access the contents of a node. This makes sense, of course, because XML is supposed to be well-formed and pretty, but those of you who know where that XML snippet came from are already laughing, because that horribly unintuitive XML is directly output from Microsoft SharePoint’s Web Services API. 🙂

Anyway, that’s besides the point. If anyone knows how to access the properties of an XML node using Javascript’s XML DOM, I would really appreciate some help. 😀

Edit: The problem may be somewhere different. I did mean attributes, not properties; that helped a bunch. However, it’s still telling me that all the XML DOM Node properties and methods are undefined; I think the actual reference I’m using to access the methods is undefined. Here is the code I use to generate it:

var xmlDoc = $.parseXML(xml);
$(xmlDoc).find('List').each (
    function ()
    {
        var id = $(this).attributes.getNamedItem("ID").value;
        alert(id);
    });

Where “xml” contains the List snippet above, and is straight XML output from SharePoint Web Services.

I was under the assumption that this code found all the nodes with type ‘List’ and iterated through them; is this incorrect?

Edit: Solution found. Apparently, when you use JQuery to encapsulate a Javascript XML DOM Node, $(this) does NOT give you the DOM element, but instead gives you a JQuery object that contains the DOM element. There are two ways around this, given the code I used above:

  1. var id = $(this).attr(‘ID’); // This is JQuery’s way of letting you access attributes within an encapsulated XML node – attr() is NOT part of the standard Javascript XML DOM, because $(this) is NOT an XML DOM element.

  2. var id = $(this).get(0).attributes.getNamedItem(“ID”).value; // This is Javascript’s way. Here, we call get(0) to return the actual XML DOM node from JQuery’s encapsulated object; after that, we can call whatever Javascript XML DOM methods we would like. I’m using this method because I know the Javascript XML DOM, and I’d prefer to use JQuery for as little as possible outside of GUI generation.

Hope that helps whoever else comes across a similar problem. 🙂

(Oh, and attributes vs properties. Good to know. :D)

  • 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-22T20:32:17+00:00Added an answer on May 22, 2026 at 8:32 pm

    The values to which you are referring are called attributes.

    Assuming you have a reference to the appropriate element:

    var mobileDefaultViewUrl = element.getAttribute('MobileDefaultViewUrl');
    

    A more full example for Mozilla-based browsers:

    var xmlText = "<root><element id='elementId' attribute1='test1' attribute2='test2' /></root>";
    
    var parser=new DOMParser();
    var dom=parser.parseFromString(xmlText,"text/xml");    
    var element = dom.getElementsByTagName('element')[0];
    
    console.log(element.getAttribute('attribute1'));
    

    In jQuery:

    var xml = "<root><element id='elementId' attribute1='test1' attribute2='test2' /></root>",
        xmlDoc = $.parseXML( xml ),
        $xml = $( xmlDoc ),
        $element = $xml.find( "element" );
    
    console.log($element.attr('attribute1'));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

All too often I want a WPF slider that behaves like the System.Windows.Forms.TrackBar of
All, I've got the following code, and looking into ways to improve its readibility
All thread create methods like pthread_create() or CreateThread() in Windows expect the caller to
All the table names are appended with a 's'? Like table test will appear
All the examples of Silverlight using MVVM use interface named IPropertyChanged. What is the
I am attempting to pull some information from my tnsnames file using regex. I
We're building an app, our first using Rails 3, and we're having to build
All, Can anyone please let me know exactly what are the performance issues between
All the articles I've found via google are either obsolete or contradict one another.
All the recent VisualSVN Server posts made me want to check it out. I

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.