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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:59:46+00:00 2026-05-26T05:59:46+00:00

I am using custom javascript functions provided at this link (http://km0.la/js/mozXPath/) to implement particular

  • 0

I am using custom javascript functions provided at this link (http://km0.la/js/mozXPath/) to implement particular XML functionality in FireFox.

Here is the code:

// mozXPath
// Code licensed under Creative Commons Attribution-ShareAlike License 
// http://creativecommons.org/licenses/by-sa/2.5/
if( document.implementation.hasFeature("XPath", "3.0") ) {
    if( typeof XMLDocument == "undefined" ) { XMLDocument = Document; }
    XMLDocument.prototype.selectNodes = function(cXPathString, xNode) {
        if( !xNode ) { xNode = this; }
        var oNSResolver = this.createNSResolver(this.documentElement);
        var aItems = this.evaluate(cXPathString, xNode, oNSResolver, 
                     XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
        var aResult = [];
        for( var i = 0; i < aItems.snapshotLength; i++) {
            aResult[i] = aItems.snapshotItem(i);
        }
        return aResult;
    }
    XMLDocument.prototype.selectSingleNode = function(cXPathString, xNode) {
        if( !xNode ) { xNode = this; } 
        var xItems = this.selectNodes(cXPathString, xNode);
        if( xItems.length > 0 ){ return xItems[0]; }
        else{ return null; }
    }
    Element.prototype.selectNodes = function(cXPathString) {
        if(this.ownerDocument.selectNodes) { 
            return this.ownerDocument.selectNodes(cXPathString, this);
        }
        else { throw "For XML Elements Only"; }
    }
    Element.prototype.selectSingleNode = function(cXPathString) {   
        if(this.ownerDocument.selectSingleNode) {
            return this.ownerDocument.selectSingleNode(cXPathString, this);
        }
        else { throw "For XML Elements Only"; }
    }
}

Assuming the XML object has been defined and loaded with XML content, here is an example of how one would access a an XML tag named “cd_rank”:

var cd_rank_XMLObj = XMLObj.selectSingleNode("cd_rank");

What I want to do is add the property “nodeTypedValue” to the selectSingleNode() function, but I’m not sure how to do this. In the Element.prototype.selectSingleNode function, I tried adding:

this.prototype.nodeTypedValue = this.textContent;

However, it’s giving me an error saying it’s undefined. I even tried adding it outside of the function, just to dumb it down and get the concept, and it also says it’s undefined:

var XMLObj.selectSingleNode.prototype.nodeTypedValue = XMLObj.textContent;
alert(XMLObj.selectSingleNode("cd_rank").nodeTypedValue);

Essentially what I’m trying to do, I suppose, is add a prototype property to a prototype function. But I need some help with this. How can i add “nodeTypedValue” such that I write “XMLObj.selectSingleNode(Path).nodeTypedValue”?

  • 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-26T05:59:47+00:00Added an answer on May 26, 2026 at 5:59 am

    Okay, I think I figured out how to add it inside the function, probably due more to luck than logic:

    Element.prototype.selectSingleNode = function(cXPathString){    
        if(this.ownerDocument.selectSingleNode) {
            var result = this.ownerDocument.selectSingleNode(cXPathString, this);
            if (result != null) {
                result.nodeTypedValue = result.textContent;
            }
            return result;
        }
        else{throw "For XML Elements Only";}
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking at using the Dojo Objective Harness (DOH) for testing some custom JavaScript
We are using jQuery in our project. We have numerous custom javascript files in
I'm using custom WordPress categories for some probably unintended functions, I will admit (things
I want to add some custom javascript functions to my design document, I can't
I'm using the code below and also seen in this fiddle http://jsfiddle.net/peter/Xt5qu/ to use
When using custom template for Login control , if we add control with ID
When using custom assemblies in a visual studio project. How does one check in
Background : I am currently using custom controls within my C# project (basic controls
I have been using custom swc based components for my new flash game. I
I'm using custom renderer on JList, but none of components rendered are accessible. list.setCellRenderer(new

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.