Thanks Dave,
But still am not able to get the thing running. i am totally new to xml and doesnt know much details of xml methods.
I have the following method,which is capturing only the 'nodes' which are NOT 'nested'.What modifications does it require,if it needs to read in the nested nodes existing for a particular Node.
public static Hashtable simpleAttrHash(Node _xml)
{
Hashtable outputHash = new Hashtable();
NodeList elements = _xml.getChildNodes();
Node target = null;
String val = null;
for(int i = 0; i < elements.getLength(); i++)
{
target = elements.item(i);
if(target.getNodeType() != 1)
continue;
NodeList children = target.getChildNodes();
if(children == null || children.getLength() != 1)
continue;
Node child = children.item(0);
if(child.getNodeType() == 3)
{
val = child.getNodeValue();
outputHash.put(target.getNodeName(), val);
}
}
return outputHash;
}
and the xml structure is as follows .
<node>
<E1>Element1</E1>
<subNode>
<SE1>Subelement1</SE1>
<SE2>Subelement2</SE2>
</subNode>
</node>
am not able to read 'SE2' using the above method.
can anyone pls help out with the above method ?
Thanks,
Raj