Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > RSS and Atom
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
RSS and Atom Ask questions, get answers, discuss creating RSS and Atom feeds or programming apps or sites that create or consume RSS/Atom. Please leave any RSS/Atom politics out of this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the RSS and Atom section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Display Modes
  #1 (permalink)  
Old July 8th, 2008, 11:36 AM
Registered User
 
Join Date: Jul 2008
Location: bangalore, karnataka, India.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to vinod.kumbar
Default xpath-nested expression

<root>
<node nodeid="12" depnode="4"/>
<node nodeid="1" frm="12,45"/>
<node nodeid="45" depnode="3"/>
<node nodeid="24" depnode="2"/>
<node nodeid="2" frm="24,36"/>
<node nodeid="36" depnode="1"/>
</root>

in the above xml code, some "node" elemenet nodes, have "frm"-attribute.

How do i write a single xpath expression, so that by passing a nodeid="1", i get "frm" attribute. Then the "frm" attribute can be parsed and searched for the nodeid="which frm tag consists" then get the attributes of those nodes.....

example---
exp1="//node[@nodeid="1"]/@frm"
exp2="//node[@nodeid="this value should be passed from the exp1"]/@depnode"

this exactly gets the attributes with 2 different expressions.
Is there any way, where we can put it in one expression.


below given is the java code(the way i have parsed using xPATH)
//sample code which is working fine with 2 xpath expressions.....

private void test() throws Exception
    {
        Node frm_values=null;
        Node dep_Node=null;
inputSource= new InputSource(new FileInputStream(new File(this.fileName)));
NodeList frm_nodes=(NodeList) xPath.evaluate("//node[@nodeid="+1+"]/@frm", inputSource, XPathConstants.NODESET);
    System.out.println("length of the .."+frm_nodes.getLength());
    for(int i=0; i<frm_nodes.getLength(); i++)
        {
frm_values=frm_nodes.item(i);
System.out.println("frm tag values.... "+frm_values.getNodeValue());
String frm_string=frm_values.getNodeValue();
String[] frm_array=frm_string.split(",");
for(int k=0; k<frm_array.length; k++)
{
System.out.println("values...."+frm_array[k]);
inputSource= new InputSource(new FileInputStream(new File(this.fileName)));
NodeList dep_list=(NodeList) xPath.evaluate("//node[@nodeid="+frm_array[k]+"]/@depnode", inputSource, XPathConstants.NODESET);
    for(int ctr=0; ctr< dep_list.getLength(); ctr++)
    {
    dep_Node=dep_list.item(ctr);
System.out.println("dependent nodes node's "+dep_Node.getNodeValue());
    }
}

}



 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
XPath 2.0 every expression stolte XSLT 5 November 24th, 2008 02:32 PM
XPath Expression NEO1976 XSLT 11 August 2nd, 2006 02:28 AM
nested xPath chetrity XML 5 June 8th, 2006 06:26 PM
Need help with XPATH Expression benomathew XML 1 May 9th, 2006 03:38 PM
Nested XPath Expression sonicDace XML 9 January 8th, 2004 11:17 AM



All times are GMT -4. The time now is 02:24 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.