Creating an xml file in my Package and the XML file content is
<?xml version="1.0" encoding="UTF-8"?>
<main>
<sub>
<Key>TL</Key>
<value>Title</value>
</sub>
<sub>
<Key>DKN</Key>
<value>Docket No.</value>
</sub>
</main>
from the main class, i have declare a String Variable and passing the Following query
String query = "prabu<in>TL";
adove string Key is TL
so now i want to read the XML file, with corresponding Key with Value and assign the value into an another string variable
String fieldName ="Title";
Can anyone please provide a suggestion how I can read the value from the xml file
If you did not simplify your XML, java XML properties would be an already existing solution.
The XML looks like:
<?xml version="1.0"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
<entry key="TL">Title</entry>
<entry key="DKN">Docket No.</entry>
</properties>
And Properties are handled as:
Properties properties = new Properties();
properties.loadFromXML(inputStream);
String key = "TL";
String defaultValue = "";
String value = properties.getProperty(key, defaultValue);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.