嗨,我想从XPath查询得到的数据的Java越来越元素
Element location = (Element) doc.query("//location[location_name='"+ locationName +"']/*").get(0).getDocument().getRootElement();
System.out.println(location.toXML());
Element loc = location.getFirstChildElement("location");
System.out.println(loc.getFirstChildElement("location_name").getValue());
但无论怎样我选择我总是得到1个节点(其becouse .get(0)
),但我不知道如何选择节点,其被查询选中。
我发现我应该将节点强制转换为元素(XOM getting attribute from Node?),但这里展示了如何选择第一个节点。
哪里已经这么久了:) +50 4 U – 2011-06-07 18:46:48