Re: Trouble converting C# XPATH to Java XPATH
843834Feb 1 2004 — edited Feb 2 2004Figured 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;
-------------------------------------------------------------------------------------------------------------------------------------------