Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Re: Trouble converting C# XPATH to Java XPATH

843834Feb 1 2004 — edited Feb 2 2004
Figured it out myself. JDom did the trick.

-------------------------------------------------------------------------------------------------------------------------------------------
import org.jdom.*;
import org.jdom.input.*;
import org.jdom.output.*;
import org.jdom.xpath.*;

///////////////////////////////////////////////////////////

double lumpSumFactor = 0.0;
double yr;

try
{
SAXBuilder builder = new SAXBuilder();
Document doc = builder.build(new File("/config/config.xml"));
XPath xpath = XPath.newInstance("descendant::lump-sum[year='"+year+"']");
Element element = (Element)xpath.selectSingleNode(doc);
String name = (String)element.getChild("name").getText();
lumpSumFactor = Double.parseDouble(name);
}
catch (Exception e)
{
System.out.println(e.toString());
}

return lumpSumFactor;

-------------------------------------------------------------------------------------------------------------------------------------------
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 1 2004
Added on Feb 1 2004
1 comment
135 views