473,789 Members | 2,337 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Which function do I use to retrieve a whole hierarchy?

I can build portions of DOM trees with jdom and xpathapi and using "new
Element()" and "appendChil d()" or "addContent ()". Which function do I
use to get a whole portion of a DOM tree though? For example, suppose I have

<foo>
<bar name="dopey">
<snafu>
Text
</snafu>
</bar>
<bar name="sleepy">
<snafu>
More text
</snafu>
</bar>
</foo>

I can use an XPath query like
"/foo/bar[@name="dopey"]/ancestor-or-self::*" but that will give me back
a *list* of all the nodes it found. I want a pointer to the top <bar>
node and I want the rest of the stuff to be in a hierarchy below that
just like it is in the XML file. Is there a way to retrieve a hierarchy?
Thank you.
Jul 20 '05 #1
1 1263
Scott Simpson <ss******@visio nsolutions.com> writes:
I can build portions of DOM trees with jdom and xpathapi and using "new
Element()" and "appendChil d()" or "addContent ()". Which function do I
use to get a whole portion of a DOM tree though? For example, suppose I have

<foo>
<bar name="dopey">
<snafu>
Text
</snafu>
</bar>
<bar name="sleepy">
<snafu>
More text
</snafu>
</bar>
</foo>

I can use an XPath query like
"/foo/bar[@name="dopey"]/ancestor-or-self::*" but that will give me back
a *list* of all the nodes it found. I want a pointer to the top <bar>
node and I want the rest of the stuff to be in a hierarchy below that
just like it is in the XML file. Is there a way to retrieve a hierarchy?
Thank you.


The Xpath to the top of the document is / which returns the root node
(document node)

I'm not sure what you mean by teh "top <bar> node as there are several
sibling bar nodes in your example.
/foo would return teh top level element
/foo/bar[1] would return the first of the bar nodes.

Once you have the node returned you can traverse the hierarchy below
that point using dom cals in your application or further Xpaths or
whatever.

David
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

41
10060
by: Alexei A. Frounze | last post by:
Seems like, to make sure that a pointer doesn't point to an object/function, NULL (or simply 0) is good enough for both kind of pointers, data pointers and function pointers as per 6.3.2.3: 3 An integer constant expression with the value 0, or such an expression cast to type void *, is called a null pointer constant.55) If a null pointer constant is converted to a pointer type, the resulting pointer, called a null pointer, is guaranteed...
3
1297
by: Marco Segurini | last post by:
Hi, Actually I am creating a hierarchy of MANAGED classes. I like to know if there is way to mark a virtual (abstract) function as "must be implemented on each derived class". example: ref class Test abstract {
4
1606
by: Agoston Bejo | last post by:
Hi, I would like to do something like this: struct A { int f(float f); }; .... int g(int(*f1)(float)) { return f1(6.5); }
2
1270
by: Alex Stevens | last post by:
Hi all. I have a class which performs some tasks for which ever form it get s bound to using a bindForm methods which accepts a form object. I'd like to do away with this method as it only ever gets used like this: BindForm(Me) Is there anyway, that I can get the form object in the class, when it is instatianted by the form?
4
10027
by: Mamatha | last post by:
Hi I need to know..how to retrieve values of Microsoft Outlook in VB,i want to retrieve how many emails contains in my inbox,outbox,sentitems etc. Please give me the solution for retrieving values of outlook in VB6.If you know the solution or code,please help me,thanks in advance. Mamatha
8
3657
by: Andy | last post by:
Hi all, i am pretty new to programming and have a (simple?) problem here: I want to populate a Treeview with data from a table. Table layout is: ID, ParentID, Description There can be infinite levels, the starting level for ParentID is 0 (this is root level). I know that I will have to make a recursive function to fill this
12
2642
by: Ima Loozer | last post by:
OK folks here is what I need help with. Lets assume I have a text field that will contain AlphaNumeric data. There is no set pattern to the field such that any given character can be either alpha or numeric. I need a function that will return the requested 'part' of the contents of the field. A 'part' would be defined as consecutive Alpha or Numeric characters in the text field. Examples: Field Name = cFoo
12
3820
by: bb nicole | last post by:
I have do a update profile for company where they can update after view their profile, but it cannot function... I need to submit the whole job portal soon, but still got many problem in my coding, could someone help me... Thanks a lot.. Below is the error: Notice: Undefined index: company_ID in C:\Apache2\Apache2\htdocs\comProfile_update.php on line 28 where line 28 is if(is_numeric($_GET)) { My whole coding as below: <?php ...
2
2406
by: sebastien.abeille | last post by:
Hello, I would like to create a minimalist file browser using pyGTK. Having read lot of tutorials, it seems to me that that in my case, the best solution is to have a gtk.TreeStore containing all the files and folders so that it would map the file system hierarchy.
0
9661
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10403
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9978
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9015
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6755
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5414
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5546
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4087
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2904
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.