Hi, I'm new of this list, and this is my first message on it. I have a problem with XPath (I think). I have the following code :
import org.dom4j.*; import org.dom4j.xpath.*; import java.util.*;
public class TDOM
{
public static void main(String[] args)
{
String xml = "<cars>";
xml += "<car><name>BMW M3</name><traction>rear</traction></car>";
xml += "<car><name>Carrera 4S</name><traction>four</traction></car>";
xml += "<car><name>Lancer EVO VII</name><traction>four</traction></car>";
xml += "</cars>";
try
{
Document document = DocumentHelper.parseText(xml);
List cars = document.selectNodes("//cars/car");
for(int i = 0; i < cars.size(); i++) { Element car = (Element)cars.get(i); System.out.println("Car " + i + " : " + car.asXML() + "");
Element name = (Element) car.selectSingleNode("./car/name"); if(name != null) System.out.println("Name : " + name.getText()); } } catch(Exception e) { e.printStackTrace(); } } }
And i need to get the "name" of each "car" but the selectSingleNode refer to entire document instead of the current node.
I search on google but without success :-(
Thanks in advance
Ciao emiliano
------------------------------------------------------- This SF.Net email sponsored by: Free pre-built ASP.NET sites including Data Reports, E-commerce, Portals, and Forums are available now. Download today and enter to win an XBOX or Visual Studio .NET. http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01 _______________________________________________ dom4j-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/dom4j-user