473,386 Members | 1,652 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

XPath. Get a tree from a plain XML sequence

Hi there,

I'm really new to XQuery, but I think it is quite powerful.
I suppose this problem is quite classical, but I have check quite a lot of sites and I cannot figure out how to solve it

Input:
Expand|Select|Wrap|Line Numbers
  1. <a/>
  2. <b/>
  3. <b/>
  4. <b/>
  5. <a/>
  6. <b/>
  7. <b/>
  8. <a/>
  9.  
Desired output
Expand|Select|Wrap|Line Numbers
  1. <a>
  2.     <b/>
  3.     <b/>
  4.     <b/>
  5. </a>
  6. <a>
  7.     <b/>
  8.     <b/>
  9. </a>
  10.  
All the elements have an ID attribute. Any suggestion?

Thanks a lot

Jose
Sep 19 '06 #1
0 1035

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: bdinmstig | last post by:
I refined my attempt a little further, and the following code does seem to work, however it has 2 major problems: 1. Very limited support for XPath features Basic paths are supported for...
2
by: ahogue at theory dot lcs dot mit dot edu | last post by:
Hello - Is there any way to match complex subtree patterns with XPath? The functions I see all seem to match along a single path from root to leaf. I would like to match full subtrees. For...
1
by: Keith Davies | last post by:
Hi All, I've got a document containing a internal lookups (I want to show a relationship hierarchy, starting at an arbitrary point, or series of points). It's easy if I know what item IDs I...
25
by: prabhat143 | last post by:
Hi, Given a singly linked, null terminated list, how can it be converted to tree? Each node in the list has three attributes: it's ID, it's parent ID and of course, the next node it's pointing...
3
by: bruce | last post by:
for guys with python/xpath expertise.. i'm playing with xpath.. and i'm trying to solve an issue... i have the following kind of situation where i'm trying to get certain data. i have a...
8
by: Jean-François Michaud | last post by:
Who in the name of #%@! thought this one out?? I noticed this behavior when trying to debug a problem I was having. I used this logical expression and some XPATH in a specific sequence of...
6
by: Hoss | last post by:
Hello. Because IE and Mozilla have such completely different XML implementations, I have created a class to handle general XML tasks, such as iterating over nodes given an xpath, evaluating an...
1
by: Floris Bruynooghe | last post by:
Hi I'm trying to use the .xpath('id("foo")') function on an lxml tree but can't get it to work. Given the following XML: <root><child id="foo"/></root> And it's XMLSchema: <?xml...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.