im new here , just wanted to try if i can get some help here. I would like to ask for some help for my problem.
I got an XML-File, and i would like to compare those Strings there with File extension for exmaple. Example.txt -> compare all Strings in XML with my File-Extension.
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href"tx ?>
<zip>
<exclusions>
<switch> .bak </switch>
<switch> .tmp </switch>
<switch> .frm </switch>
<switch> .opt </switch>
<switch> .met </switch>
<switch> .i </switch>
</exclusions>
</zip>
This is my XML Code to print it , my idea was to store all the Strings into arrays and compare them with my extension .. but i dont know how.
Hope you have some ideas for me.
Thanks
public class xmlFileExten {
public static void main(String[] args) {
try {
File file = new File(xmlFile);
DocumentBuilder dBuilder = DocumentBuilderFactory.newInstance()
.newDocumentBuilder();
Document doc = dBuilder.parse(file);
System.out.println("Root element :" + doc.getDocumentElement().getNodeName());
if (doc.hasChildNodes()) {
printNote(doc.getChildNodes());
}
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
private static void printNote(NodeList nodeList) {
for (int count = 0; count < nodeList.getLength(); count++) {
Node tempNode = nodeList.item(count);
if (tempNode.getNodeType() == Node.ELEMENT_NODE) {
System.out.println("Node Value =" + tempNode.getTextContent());