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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:42:24+00:00 2026-05-25T19:42:24+00:00

I need to generate a NodeList that represents the entire sub-tree (including attributes, comments,

  • 0

I need to generate a NodeList that represents the entire sub-tree (including attributes, comments, and namespace declarations) of a given Node in my Document.

Let’s assume my document looked like this:

<?xml version="1.0"?>
<my:root xmlns:my="http://www.my.com/#">
  <my:element type="1">
    <my:content green="true">
      <xx:content xmlns:xx="http:://www.xx.com/#"/>
    </my:content>
  </my:element>
</my:root>

Now what I want is to select all the sub-nodes of including that element itself, so that my resulting selection would represent the sub-tree

<my:element type="1">
  <my:content green="true">
    <xx:content xmlns:xx="http:://www.xx.com/#"/>
  </my:content>
</my:element>

a) How can I achieve this if e.g. the type attribute could be assumed to be unique? I’m currently using an XPath expression like

/descendant-or-self::node()[@type='1']/descendant-or-self::node()

Is there a better way to do this?

b) In another scenario I’m just given explicit Node references, without any knowledge of their context in the DOM, which means that I have no means to cleverly select the ‘anchor node’ using any describing characteristic. Is there a way to derive an XPath expression from the Node reference that would select the sub-tree of that particular node? Or is the only chance that I have in this case generating the NodeList manually, by iterating over the node and its children?

  • 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-25T19:42:25+00:00Added an answer on May 25, 2026 at 7:42 pm

    Maybe Views tree + Views Datasource would help? I’d recommend experimenting with those.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to generate some passwords, I want to avoid characters that can be
I need to generate thumbnails from a set of jpg's that need to have
I need to generate a controlled sequence of pseudo-random numbers, given an initial integer
I need to generate real Spotify playlists (not a text string that you can
I need to generate a node in a XML file with the following structure:
I need to generate a controlled sequence of pseudo-random numbers, given an initial parameter.
I need to generate a loop that would iterate through each capital letter of
I need to Generate an export script of entire Oracle Database using using SQL
I need to generate a Key from a string, such that I can always
I need to generate an id in javascript that is guaranteed to be unique.

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.