As Christian put it, use the elementText("name") to get the child element "name" from the car. But looking just at you XPath, you are at the current element "." which is already named "car", so there is no children named "car" below this one. Only the element "name" is available.

selectXXXXNode methods use XPath and are slower than going directly at the element from the tree. If you already know the pattern, then just go direct and save some CPU cycles by using the element("name") or elementText("name") methods.

Enjoy!
Dave


emiliano carlesi wrote:
Hi,
            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());
}
}


--

+------------------------------------------------------------+
| David Lucas                        mailto:[EMAIL PROTECTED]  |
| Lucas Software Engineering, Inc.   (740) 964-6248 Voice    |
| Unix,Java,C++,CORBA,XML,EJB        (614) 668-4020 Mobile   |
| Middleware,Frameworks              (888) 866-4728 Fax/Msg  |
+------------------------------------------------------------+
| GPS Location:  40.0150 deg Lat,  -82.6378 deg Long         |
| IMHC: "Jesus Christ is the way, the truth, and the life."  |
| IMHC: "I know where I am; I know where I'm going."    <><  |
+------------------------------------------------------------+

Notes: PGP Key Block=http://www.lse.com/~ddlucas/pgpblock.txt
IMHO="in my humble opinion" IMHC="in my humble conviction"
All trademarks above are those of their respective owners.




------------------------------------------------------- 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

Reply via email to