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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:09:35+00:00 2026-05-28T00:09:35+00:00

I have a XML file like this <a:books xmlns:a=ans> <a:book> <a:id> 1 </a:id> <a:title>The

  • 0

I have a XML file like this

<a:books xmlns:a="ans">
    <a:book>
        <a:id> 1 </a:id>
        <a:title>The first book</a:title>
    </a:book>
</a:books>

By default, IE recognizes the a prefixes from the xml itself when I do a XPath query on it

x.selectNodes('//a:book').length  //gives 1, as desired

But if I tell it to use the XPath selection language to go along with the other browsers then it stops recognizing the prefixes used in the original XML.

x.setProperty('SelectionLanguage', 'XPath') 
x.selectNodes('//a:book').length 
//throws an error: "Referência a um prefixo de espaço para nome não declarado: 'a'." 
// I would translate it as "reference to an undeclared namespace prefix".

I know I can use x.setProperty('SelectionNamespaces', "xmlns:a='ans'") to stop the error but is there a way to programatically get the a->ans relation, like I can by using x.createNSResolver(x) in the other browsers?

  • 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-28T00:09:36+00:00Added an answer on May 28, 2026 at 12:09 am

    You would need to access any namespace declaration attributes in the DOM and that way infer the prefix->namespace URI bindings yourself, MSXML (which IE uses) does not have any method like createNSResolver.

    [edit]
    Here is some sample code:

    function getPrefixNamespaceBindings(element) {
      var bindings = {};
      for (var i = 0,
           attributes = element.attributes,
           l = attributes.length;
           i < l;
           i++)
      {
        if (attributes[i].prefix === 'xmlns')
        {
          bindings[attributes[i].nodeName.substring(attributes[i].nodeName.indexOf(':') + 1)] = attributes[i].nodeValue;
         }
      }
      return bindings;
    }
    
    var doc = new ActiveXObject('Msxml2.DOMDocument.6.0');
    doc.loadXML('<xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:svg="http://www.w3.org/2000/svg" id="root" xml:lang="en">...</xhtml:html>');
    
    var bindings = getPrefixNamespaceBindings(doc.documentElement);
    for (var prefix in bindings) {
      document.body.appendChild(document.createTextNode(prefix + '="' + bindings[prefix] + '" '));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an XML file that looks like this <library> <book> <title>Title</title> <author>author</author> <price>20</price>
I have an XML file that starts like this: <Elements name=Entities xmlns=XS-GenerationToolElements> I'll have
I have an options_menu.xml file like this: <?xml version=1.0 encoding=utf-8?> <menu xmlns:android=http://schemas.android.com/apk/res/android> <item android:id=@+id/search
I have an XML file that looks like this: <SiteMenuItems> <SiteMenuItem text=Home navigateurl=/Default.aspx tooltip=Return
I have a sample xml file that looks like this: <Books> <Category Genre=Fiction BookName=book_name
Assume I have this XML... <books> <book> <author> <title> <publish_date> <isbn_number> <book> </books> ...how
i have an xml file that looks something like this <library> <book name=ABC> <chapter
I have an xml file like this: <?xml version=1.0 encoding=UTF-8?> <todo> <list><item>first</item><item>second</item></list> <list><item>first</item><item>second</item></list> </todo>
I have an xml file with the following data: <BOOKS> <BOOK> <TITLE image=./images/govnahDesign.jpg>Bible</TITLE> <CATEGORY>Book</CATEGORY>
I have an XML file like this: <lib:library> <lib:book> XML </lib:book> <lib:book> XPath </lib:book>

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.