i want to get the vaule of type in root element.
if i try with getAttributeValue("type") it returns null value
here the sample xml and code. i'm using org.jdom2.Element for parsing help will be appriciated.
Sample xml
<root type="new">
<msg size="30">
<attr uid="0" value="500" />
<attr uid="15" value="XHYs5"/>
</msg>
</root>
my code
SAXBuilder builder = new SAXBuilder();
File xmlFile = new File(filename);
Document document;
try {
document = (Document) builder.build(xmlFile);
} catch (JDOMException | IOException e1) {
throw new ISOException("Error reading xml file");
}
Element rootNode = document.getRootElement();
typeVal=rootNode.getAttributeValue("type");
System.out.println(typeVal);
Perhaps you have bad
imports
. Your code works for me.