How get all child elements from XML
967752Oct 11 2012 — edited Oct 15 2012Hi
I have one xml i tried to parse that xml using dom parser and i need to get some child elements using java
<Group>
<NAME>ABC</NAME>
<Age>24</AgeC>
---------some data here......
<Group1>
<group1Category>
<NAME>ABCTest</NAME>
<age>27</Age>
----Some data here
<group1subcategory>
<subcategory>
<NAME>ABCDEF</NAME>
<age>28</Age>
my intention was
get group name (here ABC) i need all other name value from group1category ,group1 subcategory but pblm that
my xml contains any number of Group nodes...but only i want name contains ABC
i wriiten code like this
DocumentBuilderFactory factory = DocumentBuilderFactory
.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(xmlFile);
NodeList nodeList = document.getElementsByTagName("*");
for (int i = 0; i < nodeList.getLength(); i++)
{
Element element = (Element) nodeList.item(i);
}
what is next step i need to do..please help