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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:42:22+00:00 2026-05-13T22:42:22+00:00

I am trying to identify all the nodes in a tree that lead to

  • 0

I am trying to identify all the nodes in a tree that lead to a specific node.

I am trying to accomplish this through either MSSQL XML (2005) or by the Microsoft.XMLDOM in ASP classic.

I know the logic with XPATH but SQL Server does not support the ancestor-or-self axis and XMLDOM seems to choke on the :: notation..

The xpath that works when i test it in XPATH testers is

//static[@id=6]/ancestor-or-self::static

my XML (generated recursively in sql server) looks like

<root>
  <static id="1" title="some title 1" />
  <static id="2" title="some title 2">
     <children>
        <static id="3" title="some title 3" />
        <static id="4" title="some title 4">
          <children>
            <static id="5" title="some title 5" />
            <static id="6" title="some title 6" />
          </children>
        </static>
     </children>
  </static>
  <static id="7" title="some title 7" />
</root>

the XPATH should select nodes with id (2,4,6) in any order, so i can add an attribute to all of them ..

This is for a menu system, where i only know the selected leaf, and need to mark as hilited all the nodes leading to it..

I would appreciate any assistance in either overcoming the XMLDOM choking
(running xml.documentElement.selectNodes("//static[@id=6]/ancestor-or-self::static") produces the following error: Expected token 'eof' found ':'. //static[@id=6]/ancestor-or-self-->:<--:static)

or with finding an alternative solution. Maybe finding all nodes that contain the specific node (with id = 6 ) at any depth..

  • 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-13T22:42:23+00:00Added an answer on May 13, 2026 at 10:42 pm

    Running on W2K3, using IIS6 i tested the MSXML2.XMLDomDocument.4.0 version.

    Dim XMLDom ''# As MSXML2.DOMDocument40
    
    Set XMLDom = CreateObject("MSXML2.DOMDocument.4.0")
    Call XMLDom.setProperty("SelectionLanguage", "XPath")
    
    Call XMLDom.loadXML( {document as described above - mistakes in original xml doc)
    )
    
    
    Dim originalQuery ''# As String
    originalQuery = "//static[@id=6]/ancestor-or-self::static"
    
    Dim replacementQuery ''# As String
    replacementQuery = "//static[descendant::static[@id=6] or @id=6]"
    
    
    Dim XmlElemList ''# As MSXML2.IXMLDOMNodeList
    Set XmlElemList = XMLDom.documentElement.selectNodes(originalQuery)
    
    Dim XmlElemList2 ''# As MSXML2.IXMLDOMNodeList
    Set XmlElemList2 = XMLDom.documentElement.selectNodes(replacementQuery)
    
    Dim XmlElem ''# As MSXML2.IXMLDOMElement
    Call Response.Write("Using original query : '" & originalQuery & "' (" & XmlElemList.Length & ")<br>")
    For Each XmlElem In XmlElemList
        Call Response.Write("XmlEntry : " & XmlElem.getAttribute("id") & "<br>")
        Call Response.Write("****<br>")
    Next
    
    Call Response.Write("Using replacement query : '" & replacementQuery & "' (" & XmlElemList2.Length & ")<br>")
    For Each XmlElem In XmlElemList2
        Call Response.Write("XmlEntry : " & XmlElem.getAttribute("id") & "<br>")
        Call Response.Write("****<br>")
    Next
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

gtk.Builder is capable to identify all signals that a GUI (described in a XML
I am trying to identify all the <UL> that contain a menu list by
I have a table that has redundant data and I'm trying to identify all
I'm trying to identify if this is an IIS issue or a code issue.
I am trying to identify duplicate serial numbers from the following xml using XPath
I am trying to identify SQL INSERTS that occur when a record is viewed
I am trying to filter an XML based on multiple parameters that I have
All, I am trying to create a table to receive user inputs (UGC). This
Hello All , I am trying to use preg_match to identify if a single
I am trying to build a mysql query to list all column a's that

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.