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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:58:25+00:00 2026-06-11T17:58:25+00:00

I am trying to make some xpath queries in IE9, with some a sort

  • 0

I am trying to make some xpath queries in IE9, with some a sort succes, but certainly its just trying and I cannot figure out clearly what can work and what not.

I want to do two things:

  1. query elements in custom namespace from loaded xml
  2. query elements from inline svg which have custom namespace attributes

Point one works, using this code:

doc.setProperty( "SelectionLanguage", "XPath" );
doc.setProperty( "SelectionNamespaces", xpathNsString );
svg = cloneSVGNode( doc.selectSingleNode( '//graphic/svg:svg' ) );

where doc is a reference to the loaded xml, xpathNsString is:

"xmlns=\"http://www.w3.org/1999/xhtml\" " +
"xmlns:svg=\"http://www.w3.org/2000/svg\" "+
"xmlns:dc=\"http://purl.org/dc/elements/1.1/\" "+
"xmlns:cc=\"http://creativecommons.org/ns#\" "+
"xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\" "+
"xmlns:sodipodi=\"http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd\" "+
"xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" "+
"xmlns:mine=\"http://www.mine.org\" "+
"xmlns:html=\"http://www.w3.org/1999/xhtml\"";

and cloneSVGNode a function which clones the entire result, so that I can append it to the DOM — that works.

Later on in the code I want to query some of the elements of the (now in the DOM) SVG, using a query like this:

//svg:g[@mine:my-name="my-value"]

but this does not work. I read that IE does not support xpath queries on DOM elements, but how described in this stackoverflow question there seems to be way of doing this. So I grabbed a version of the framework mentioned in the answer of the question (http://sourceforge.net/projects/html-xpath/) and made some tests.
As result I was able to get some html-elements, but it refuses to work for namespaces and svg, what worked on “plain xml”. Nevertheless, by glancing at the lib’s sourcecode I could see the following strategy (I am not totally sure about this, but I think all in all it is like this):

  1. clone the node into an new xml doc
  2. query xpath
  3. return the counterpart node of the real node

So, is it possible to make IE9 make namespaced xpath queries of the DOM, when it is possible on xml and dom nodes are converted to xml?

Greetings philipp

EDIT:

I went on trying and finally i could succeeded, somehow, the code is quiet a mess but it delivers results. So I now I can say: “the answer is YES, it’s possible.”. It still needs some tests, but the overall approach is:

  1. create a new empty xml document
  2. set the appropriate namespace property (mentioned above) !IMPORTANT
  3. walk recursively through the tree of the context document, clone all elements by creating new elements through the new xml document,
  4. thereby: generate unique id from the element of the context document and assign it to the cloned element and to the element of the context document, if it has none. Than insert an object that contains the ‘original’ and the ‘cloned’ element in a hashmap keyed by the id.
  5. query the new document with xpath
  6. retrieve the result, get the id and get the original element from the map.
  7. I decided to remove all id’s from the elements which originally had none.

DONE…

If one is intressed I can post some code…

  • 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-11T17:58:27+00:00Added an answer on June 11, 2026 at 5:58 pm

    So, based on my edit, I tweaked / patched this script so that namespaces work and added some getter’s to bring the API closer to the standard. A test-page can be seen here. It works great for my purposes but has its downsides, just because it is a kind of hack, so I include the script only if IE is detected.

    Issues:

    • the dom is filled up with IDs to fulfill step 6 of the question above,
    • an ‘onpropertychange’ listener is attached to every element in the DOM,
    • performance in ie is up to 20 times slower,
    • strangely not all namespaced items are found by IE,
    • …

    For now I will close my researches about xpath usage on the clientside and conclude this:

    If one considers to use all the namespace features of xml and xpath on the clientside it can work if the following things are done:

    • the website has to be delivered with an Content-type: application/xhtml+xml header, so the page must consist of valid xhtm,
    • also there must be an X-UA-Compatible: IE=9 header with an <meta http-equiv="X-UA-Compatible" content="IE=9" /> tag,
    • namespaces must be declared ahead, on the test-page and in the patched script this is done with the namespace resolver,
    • one should check if IE really finds elements for all the needed queries before going really productive and
    • one should consider that IE xpath-queries are quiet slow, so it might be no good idea to use them extensively, or to ue IE, but that is another question.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to make some sort of timeline, but I can not keep
I'm trying to make some ajax-functionality in my web application, but I cannot get
I'm trying to make some text bold using HTML, but I'm struggling to get
I'm trying to make some social share buttons at my site, but the urls
I'm trying to make some sort of delay in the view controllers changing. I
Currently I'm trying to make some sort of vertical auto-scrolling. This is my code
I am trying to parse some xml with saxon to make some xpath querying
I'm trying to make some custom Google maps info windows, but I'm getting the
I'm trying to make some static controls transparent on a windows dialog, but I'm
Im trying to make some queries, first, I do this one (and works): SELECT

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.