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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T08:54:56+00:00 2026-05-15T08:54:56+00:00

So I have two nodes of elements that I’m essentially trying to join. I

  • 0

So I have two nodes of elements that I’m essentially trying to join. I want the top level node to stay the same but the child nodes to be replaced by those cross referenced.

Given:

<stuff>
  <item foo="foo" boo="1"/>
  <item foo="bar" boo="2" />
  <item foo="baz" boo="3"/>
  <item foo="blah boo="4""/>
</stuff>

<list  a="1" b="2">
  <foo>bar</foo>
  <foo>baz</foo>
</list>

I want to loop through “list” and cross reference elements in “stuff” for this result:

<list  a="1" b="2">
  <item foo="bar" boo="2" />
  <item foo="baz" boo="3"/>  
</list>

I want to do this without having to know about what attributes might be on “list”. In other words I don’t want to have to explicitly call them out like

attribute a { $list/@a }, attribute b { $list/@b }
  • 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-15T08:54:57+00:00Added an answer on May 15, 2026 at 8:54 am

    Use:

    $list1/item[@foo = $list2/item/@foo]

    This selects all <item> elements in $list1 the value of whose foo attribute is equal to the foo attribute of one of the <item> elements in $list2.

    In order to copy all attributes of the <list> element, do something like this:

      for $attr in /whateverIsthePathLeadingToList/list/@*
        return 
          attibute {name($attr)} {$attr}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Imagine that you have Nokogiri nodes representing the <a> elements in the following two
So I have two tables structured like so: CREATE TABLE #nodes(node int NOT NULL);
I have two custom controls that are analogous to a node and the control
For each agency node I need to find the stmt elements that have the
I have two elements src and dest src and dest are in different DOM-nodes,
I am trying to select all the <set>erase</set> elements such that if two or
I have two XML docs that I've created and I want to combine these
I have two XML files. They are similar, but there are two nodes of
I have several nodes (undirected graph, bidirecional) ... Each two nodes have a distance...
I have two tree, which contains nodes, after I've created them, I take all

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.