473,396 Members | 1,772 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,396 software developers and data experts.

selecting parent node with xpathAPI

Hi all,

My XML file is as shown below:

<?xml version="1.0" ?>
<messages>
<message>
<code>100</code>
<text>Unknown application error</text>
</message>
</messages>

My java code:

Element root_element = msg_doc.getDocumentElement();
String xpath_query = "/messages/message/code/text()='100'/parent::*";

NodeList nl=XPathAPI.selectNodeList(root_element, xpath_query);

What I want to do is select the parent node of the "code" node that
contains value 100?
But the code above gives me TransformationException.

Please help me out at the earliest. Thanks in advance for all your
help.

regards,

asd

Jul 20 '05 #1
1 1405


ar******@yahoo.com wrote:

My XML file is as shown below:

<?xml version="1.0" ?>
<messages>
<message>
<code>100</code>
<text>Unknown application error</text>
</message>
</messages>

My java code:

Element root_element = msg_doc.getDocumentElement();
String xpath_query = "/messages/message/code/text()='100'/parent::*";

NodeList nl=XPathAPI.selectNodeList(root_element, xpath_query);


If the XPath is relative to the document element then you need
message[code = '100']
For an absolute XPath you need
/messages/message[code = '100']

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 20 '05 #2

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

Similar topics

2
by: Scott Simpson | last post by:
Can you query from a non-root node using XPathAPI's function selectNodeList(Node contextNode, java.lang.String str)? I'm trying this using the XPath expression "//*" and I'm getting nothing back. I...
2
by: dannielum | last post by:
Hi all, I am trying to write a Binary Search Tree that each of its node will have 3 node pointers: left, right and parent. I need a parent pointer for some the purpose of my project. Without the...
3
by: Tamir Kamara | last post by:
Hi, I have the following xml file which is part of a n-level tree: <TREENODES> <TreeNode Text="A1" NodeData="1" NavigateUrl="" ImageUrl=""> <TreeNode Text="A2" NodeData="12" NavigateUrl=""...
2
by: Saurabh Sharma | last post by:
Hi, I am using Dom Parsing in Xml. I am the parent node and it has many children and each children has many children. I want to select children with a given name . Is there any method by which we...
1
by: Abdul H S via DotNetMonster.com | last post by:
I am facing difficulty to make sql on the basis of user selected node in treeview.After selection of the particulare treenode I want to traverse the hierarchy up to rootnode.plz help me regarding...
4
by: darrel | last post by:
I've done a bit of transoforming XML in ASP.net by passing it to an XSL file and returning the results. I'm not trying to navigate an XML file and just return one value. I could use XSL for...
1
by: jdhcards | last post by:
Hello, I've been banging my head against a problem all day without a solution, and I'm hoping you all can help. I've got a piece of XML that defines a set of elements in a flat list. Each of...
0
by: Satiz | last post by:
Hi All, I've a TreeView(IE Webcontrol) and a DataGrid in my VS.Net 2003 ASP.Net web form. My problem : If i select a particular node(it may be parent, child or leaf), then the corresponding...
1
by: DeveloperX | last post by:
Hi, I should probably start with my XML as it makes it easier to explain the problem. <?xml version="1.0" encoding="utf-8" ?> <aa note="top level"> <b1 note="b1"> <c1 note="b1 c1"> <d1...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
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,...

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.