Skip to content
Advertisement

get key value Pairs from XML file in Java

I have to get Key and values from XMl File, I am getting Key but not value

JavaScript

XML File:

JavaScript

Result Should be Like this : usb: 100,

charger: 200

Advertisement

Answer

The values 100 and 200 are in Textnodes. You can get the content with:

laptopElement.getTextContent()

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement